Simple Coding Help - No Promise.

manny.here

Well-Known Member
Hi Guys,

A bit different question than AFL coding rather it is on backtesting and using in realtime.

I am coding a strategy for short term intra trading in 15 mins timeframe. With SetTradeDelays 0 it gives excellent results but with SetTradeDelays 1 it does not give good results.

Is it possible to use strategies with SetTradeDelays 0 and anyone using it.

Let me know if the question does not belong here and I'l post in a thread.
 
Good evening seniors

I need a AFL exploration for the following conditions.

1. Price closing below ichimoku cloud and supertrend triggering sell at the same time
2.Price closing above cloud and supertrend triggering buy signal at the same time

ignoring all other signals by both supertrend and ichimoku cloud
Time frame -- 5 minute
Please consider this.
 
Hello
can any learned member please fix the error of the given afl code
This afl is for view 4p anaysis . but i am getting error on my amiborker 6.20.1

I have searched over net and found this afl but its not working with ami 6.20.1

please fix it .
Thanks
 

Attachments

toocool

Well-Known Member
hi

how to put multiple strikes open interest indicator in one chart as a line,......... as indicator is already given in amibroker but plots only 1 strike at a time

Regards
 

bunti_k23

Well-Known Member
can anybody teach me how can i put buy on next bar only if it crosses High if this bar...?

Let me try to put it in better words ,..
First i setup buying conditions call it conditionBuy ..
when conditionBuy is True, All i want is Ami to put a Stop Limit buy order above current BAR high.

If stock fails to cross HIGH in next bar, it should set conditionBuy to FALSE again.

It can be done easily in EasyLanguage but dont know how to get it done in Amibroker (i have a very little experience with amibroker , i m learning it)

Thanks and Regards
hello trade4learn bro, i was also looking for same thing someone from helped me on this i dont know if its working or not but lets see i will post the code here you check it and let me know we will try to improve it here...

the orignal code

Code:
/////////////////

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );



SetBarsRequired(10,10);
Factor1=Optimize("Factor1",0.5,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount-1; i++) {
      TrendUp1[i] = Null;
      TrendDown1[i] = Null;
    
      trend1[i]=1;
 
      
      if (Close[i]>Up1[i-1]) {
        trend1[i]=1;
        if (trend1[i-1] == -1) changeOfTrend1 = 1;
        
      }
      else if (Close[i]<Dn1[i-1]) {
        trend1[i]=-1;
        if (trend1[i-1] == 1) changeOfTrend1 = 1;
      }
      else if (trend1[i-1]==1) {
        trend1[i]=1;
        changeOfTrend1 = 0;     
      }
      else if (trend1[i-1]==-1) {
        trend1[i]=-1;
        changeOfTrend1 = 0;
      }

      if (trend1[i]<0 && trend1[i-1]>0) {
        flag=1;
      }
      else {
        flag=0;
      }
      
      if (trend1[i]>0 && trend1[i-1]<0) {
        flagh=1;
      }
      else {
        flagh=0;
      }
      
      if (trend1[i]>0 && Dn1[i]<Dn1[i-1]){
        Dn1[i]=Dn1[i-1];
      }
      
      if (trend1[i]<0 && Up1[i]>Up1[i-1])
        { Up1[i]=Up1[i-1];
      }
      
      if (flag==1)
      {  Up1[i]=(H[i]+L[i])/2+(Factor1*iATR1[i]);;
        }
      if (flagh==1)
        { Dn1[i]=(H[i]+L[i])/2-(Factor1*iATR1[i]);;
        }
      if (trend1[i]==1) {
        TrendUp1[i]=Dn1[i];
        if (changeOfTrend1 == 1) {
            TrendUp1[i-1] = TrendDown1[i-1];
            changeOfTrend1 = 0;
        }
      }
      else if (trend1[i]==-1) {
        TrendDown1[i]=Up1[i];
        if (changeOfTrend1 == 1) {
            TrendDown1[i-1] = TrendUp1[i-1];
            changeOfTrend1 = 0;
        }
      }
  }

Plot(TrendUp1,"Trend1",colorWhite);
Plot(TrendDown1,"Down1",colorWhite);


Buy= TrendUp1 > Ref(TrendUp1,-1) AND C > O;
Sell= TrendDown1 < Ref(TrendDown1,-1) AND C < O;


Buy[BarCount-1]=Null;
Sell[BarCount-1]=Null;

Cover=Buy;
Short=Sell;


shape = Buy * shapehollowUpArrow + Sell * shapehollowDownArrow;
PlotShapes( shape, IIf( Buy, colorWhite, colorWhite ),0, IIf( Buy, Low, High ) );

code with condition

Code:
/////////////////

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );



SetBarsRequired(10,10);
Factor1=Optimize("Factor1",0.5,5,10,2);
Pd1=Optimize("ATR Periods1",5,1,10,1);
Up1=(H+L)/2+(Factor1*ATR(Pd1));
Dn1=(H+L)/2-(Factor1*ATR(Pd1));
iATR1=ATR(Pd1);
TrendUp1=TrendDown1=Null;
trend1[0]=1;
changeOfTrend1=0;
flag1=flagh1=0;

for (i = 1; i <BarCount-1; i++) {
      TrendUp1[i] = Null;
      TrendDown1[i] = Null;
    
      trend1[i]=1;
 
      
      if (Close[i]>Up1[i-1]) {
        trend1[i]=1;
        if (trend1[i-1] == -1) changeOfTrend1 = 1;
        
      }
      else if (Close[i]<Dn1[i-1]) {
        trend1[i]=-1;
        if (trend1[i-1] == 1) changeOfTrend1 = 1;
      }
      else if (trend1[i-1]==1) {
        trend1[i]=1;
        changeOfTrend1 = 0;     
      }
      else if (trend1[i-1]==-1) {
        trend1[i]=-1;
        changeOfTrend1 = 0;
      }

      if (trend1[i]<0 && trend1[i-1]>0) {
        flag=1;
      }
      else {
        flag=0;
      }
      
      if (trend1[i]>0 && trend1[i-1]<0) {
        flagh=1;
      }
      else {
        flagh=0;
      }
      
      if (trend1[i]>0 && Dn1[i]<Dn1[i-1]){
        Dn1[i]=Dn1[i-1];
      }
      
      if (trend1[i]<0 && Up1[i]>Up1[i-1])
        { Up1[i]=Up1[i-1];
      }
      
      if (flag==1)
      {  Up1[i]=(H[i]+L[i])/2+(Factor1*iATR1[i]);;
        }
      if (flagh==1)
        { Dn1[i]=(H[i]+L[i])/2-(Factor1*iATR1[i]);;
        }
      if (trend1[i]==1) {
        TrendUp1[i]=Dn1[i];
        if (changeOfTrend1 == 1) {
            TrendUp1[i-1] = TrendDown1[i-1];
            changeOfTrend1 = 0;
        }
      }
      else if (trend1[i]==-1) {
        TrendDown1[i]=Up1[i];
        if (changeOfTrend1 == 1) {
            TrendDown1[i-1] = TrendUp1[i-1];
            changeOfTrend1 = 0;
        }
      }
  }

Plot(TrendUp1,"Trend1",colorWhite);
Plot(TrendDown1,"Down1",colorWhite);


Buyset = Cross(H,TrendUp1);
Sellset = Cross(TrendDown1,L);
Buy=Cross(H,ValueWhen(buyset,H)) AND C > O;
Sell=Cross(ValueWhen(sellset,L),L) AND C < O;


Buy[BarCount-1]=Null;
Sell[BarCount-1]=Null;

Cover=Buy;
Short=Sell;


shape = Buyset * shapehollowUpArrow + Sellset * shapehollowDownArrow;
PlotShapes( shape, IIf( Buyset, colorWhite, colorWhite ),0, IIf( Buyset, Low, High ) );
 
Hi all,
I try to write a strategy with different exits and this is my idea:

enter when MA20 crosses over MA50
When profit (high since buy) is less than 5% then
the system will exit:
-50% of position if MA20 as trailing stop is hit
-50% of position if MA50 as trailing stop is hit
-Max loss is fixed at 5%
When profit is between 5% and 20% then
the system will exit
-50% of position if MA20 as trailing stop is hit
-50% of position if MA50 as trailing stop is hit
-Max loss is fixed at 0% since profit is more than 5% already (move max stoploss to entry point)
When profit is higher than 20% then
the system will exit
-100% of position if MA10 as trailing stop is hit

Anyone can help me please?
 

MSN1979

Well-Known Member
Hi

Lets say I draw and Free Line or Trend Line on chart, is it possible to print the angle of trend line on chart?

For example After I draw a Trend Line, it should print the angle of line on the chart itself

1577519589573.png


By angle I mean degree angle or in degrees
 
Last edited:
Hi

Lets say I draw and Free Line or Trend Line on chart, is it possible to print the angle of trend line on chart?

For example After I draw a Trend Line, it should print the angle of line on the chart itself

View attachment 39529

By angle I mean degree angle or in degrees
cant say for afl or any other thing
but u can measure this angle manually, easily
 

Similar threads