Why i=0; is not a numeric in afl

MSN1979

Well-Known Member
#31
As I have explained in my post, the breakout message appears only after the candle is complete. That means only after the candle is fully formed. In the chart you posted it is the second candle of the day in 15 min timeframe. Therefore, after 9:45 it will show the break out message. Just change the chart time to 5minutes and the message appears as soon as the 5minute candle is completed.

-Anant
is it possible to trigger ass soon as the breakout happens, we might have a very late entry waiting for candle close confirmation
 

asnavale

Well-Known Member
#32
If you use much lower timeframe, it is possible. For example 1 second, 3 second or even tick data. It depends on the lowest timeframe you can use as per your data feed and refresh rate.

Ok, it is past midnight and I am going to sleep. Just post your questions in the thread and I will reply tomorrow morning. (It will be evening in India)

-Anant
 

MSN1979

Well-Known Member
#33
If you use much lower timeframe, it is possible. For example 1 second, 3 second or even tick data. It depends on the lowest timeframe you can use as per your data feed and refresh rate.

Ok, it is past midnight and I am going to sleep. Just post your questions in the thread and I will reply tomorrow morning. (It will be evening in India)

-Anant
Hi anant, my code is working good now

I am using Long positions ( Buy and Sell ) Orders and For shorts ( Short and Cover ) Orders. But when I go to Scan window to check my trades it shows me a lot of Trades. I just did scan for 1 day. 1 Trade Executed as per code but scan window shows a lot of trades. Please guide me what am I doing wrong?

1563110333806.png
 
Last edited:

MSN1979

Well-Known Member
#34
Hi Anant Sir / Happy Sir

This is my code so far. I have made some modifications.

It will only show trade after Candle Close, How can I fix the code to work in such a way that it should show me trade as soon as the breakout happens. Secondly Please check the above posted exploration, It shows me trade every 15 minutes while in real time code works fine.

PS: I tried copy pasting couple of times, for some weird reason traderji is not letting post H [ i ]

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("MSNOBR");

SetChartOptions(0, chartShowDates | chartWrapTitle);
SetBarsRequired(sbrAll);

FontSize = Param("Font Size", 11, 8, 36, 1);

GfxSelectFont("Arial", FontSize);
GfxSetTextColor(colorWhite);
GfxSetBkColor(colorBlue);

NewDay = Day() != Ref(Day(), -1);

H15 = ValueWhen(NewDay, TimeFrameGetPrice("H", in15Minute));
L15 = ValueWhen(NewDay, TimeFrameGetPrice("L", in15Minute));
BI = ValueWhen(NewDay, BarIndex(), 1);

GfxTextOut("Opening Bar High: " + StrFormat("%1.2f", LastValue(H15)), 0, 25);
GfxTextOut("Opening Bar Low : " + StrFormat("%1.2f", LastValue(L15)), 0, 45);


trade_no=0;
x=0;
y=0;

if (trade_no<1)
{
for(i = LastValue(BI); i < BarCount - 1; i++)
{

if (H > H15)
{
Buy= H15;
GfxTextOut( "Buy Order Exectuted at " + StrFormat("%1.2f", H15), 0,65);
trade_no=1;
x=1;
break;

}


if (L < L15)
{
Short= L15;
GfxTextOut( "Short Order Exectuted at " + StrFormat("%1.2f", L15), 0,85);
trade_no=1;
y=1;
break;
}



}
}


if (trade_no>0 AND x>0)
{
for(i = LastValue(BI); i < BarCount - 1; i++)
{

if (L < L15)
{
Sell = L15;
GfxTextOut( "Sell Order Exectuted at " + StrFormat("%1.2f", L15), 0,105);
break;

}
}
}


if (trade_no>0 AND y>0)
{
for(i = LastValue(BI); i < BarCount - 1; i++)
{

if (H > H15)
{
Cover = H15;
GfxTextOut( "Cover Order Exectuted at " + StrFormat("%1.2f", H15), 0,125);
break;

}
}
}




_SECTION_END();
 
#35
Not checked your code, just glanced through it, but why are you using loops ?

Once you have defined H15 / L15, BO/BD can be simply

BO = Cross(H, H15); //Buy
BD = Cross(L15, L); //Short



.
 

MSN1979

Well-Known Member
#36
Not checked your code, just glanced through it, but why are you using loops ?

Once you have defined H15 / L15, BO/BD can be simply

BO = Cross(H, H15); //Buy
BD = Cross(L15, L); //Short



.
Hi thanx, Cross Function should do the Trick. I will test later today.

PS: I am using loop, to keep a track of counter TRADE NO. I only want to execute 1 trade per day. After that any other Trades it ignores
 

asnavale

Well-Known Member
#37
Hi anant, my code is working good now

I am using Long positions ( Buy and Sell ) Orders and For shorts ( Short and Cover ) Orders. But when I go to Scan window to check my trades it shows me a lot of Trades. I just did scan for 1 day. 1 Trade Executed as per code but scan window shows a lot of trades. Please guide me what am I doing wrong?

View attachment 36183

Hi MSN,

Scan looks for Buy and Sell (Short and Cover) signal only. Does not consider Filter or any other condition you define. Since you use Buy = H15 when H1 is higher than H15, every candle for which H is higher than H15 generates a Buy signal. (And similarly for Sell, Short and Cover). Therefore, when scan is running, every occurrence of H > 15 gets added to Scan result. That is why you are getting so many results in scan. As far as trades are concerned, your condition of terminating more than one trade works and prevents further trades. I hope you get the point.

-Anant
 

Similar threads