I can Create AFL but Need Strategy

sr114

Well-Known Member
#41
Condition based on Opeing Price

Buy

Buyentry=Openprice+(openprice*0.382%)
tgt1=entryprice+(entryprice*0.618%)
tgt2=entryprice+(entryprice*1%)
If buy trigger stoploss starts days low and trailing

Sell

Sellentry=Openprice-(openprice*0.382%)
tgt1=entryprice-(entryprice*0.618%)
tgt2=entryprice-(entryprice*1%)
If sell trigger stoploss starts days high and trailing

Also need the Messageboard
any other condition to fulfill for the buy or sell

rgds
subroto
 

sr114

Well-Known Member
#43
No sir i feel its enough, is it possible to create and send to me sir
no its not enough - there must be some other condition .

otherwise - simultaneously both buy and sell will be activated depending og the opening price, there must be some other filter required

rgds
subroto
 
#44
Sir daily market opening first candle only we take none for other candle
position closing end of day, next day new signal. you check it its works fine.

For Example

Thursday mcx crude open 5267
for these conditions
buy 5287 tgt1 5319 and tgt2 5339
sell 5246 tgt1 5214 and tgt2 5194
buy triggered at 5287 then hits end of day high 5320 Thursday low 5255

As the same natural gas open 222.8
for these conditions
buy 223.65 tgt1 225 tgt2 225.9
sell 221.95 tgt1 220.5 tgt2 219.73
buy trigger at morning at 223.65 high made 224.4 then evening
sell trigger at 221.95 low made 217

Also silver,zinc selling 1 tgt reached, lead 2nd tgt reached, copper stoploss trigger
90% 1st tgt will reached check it sir



per day maximum 2 trades and we follow trailing stoploss is good one
please check it sir
 
Last edited:

sr114

Well-Known Member
#47
sr114...
It is very difficult to define market opening price...I think
Bewinner

That why i asked for other filters for the entry and exit condition.

if for sake of argument we take the prices at 09.15.05 then u can argue that why not prices at 09.20.01 or another1 will ask why not after 10 min of opening.

basically this system is like ORB (opening range breakout) with the exception in orb we take either the hi or lo prices for the condition and in this case we take the opening prices. and so it will try to depict a band - a band of extraordinary conditions and in every bar u will find the up and down arrows depicting the buy and sell.

also another innovative concept - some fibo ratios are used here - the 38.2 the buy and sell conditions and 68.1 and 100 % ratios for reaching the targets

i may be wrong - but i understood this stuff and this is the concept behind the system

regards
subroto
 
#48
Condition based on Opeing Price

Buy

Buyentry=Openprice+(openprice*0.382%)
tgt1=entryprice+(entryprice*0.618%)
tgt2=entryprice+(entryprice*1%)
If buy trigger stoploss starts days low and trailing

Sell

Sellentry=Openprice-(openprice*0.382%)
tgt1=entryprice-(entryprice*0.618%)
tgt2=entryprice-(entryprice*1%)
If sell trigger stoploss starts days high and trailing

Also need the Messageboard

sir you have told 90% suceess rate to reach 1st target. Please tell me how many days back tested by sirji in MCX

thanks
 
#49
Bewinner

That why i asked for other filters for the entry and exit condition.

if for sake of argument we take the prices at 09.15.05 then u can argue that why not prices at 09.20.01 or another1 will ask why not after 10 min of opening.

basically this system is like ORB (opening range breakout) with the exception in orb we take either the hi or lo prices for the condition and in this case we take the opening prices. and so it will try to depict a band - a band of extraordinary conditions and in every bar u will find the up and down arrows depicting the buy and sell.

also another innovative concept - some fibo ratios are used here - the 38.2 the buy and sell conditions and 68.1 and 100 % ratios for reaching the targets

i may be wrong - but i understood this stuff and this is the concept behind the system

regards
subroto
Ok Sorry to waste your time
 
#50
Dear sir,

Can you place the Buy sell arrow and plot the stoploss price for following afl, bcoz i have confused where to buy and sell


_SECTION_BEGIN("Supp and Res");
/*==============================================================================
Global Settings
==============================================================================*/
SetFormulaName("TT Support Resistance 1.2");
SetOption("InitialEquity", 1000000);
SetOption("NoDefaultColumns", True );
SetOption("CommissionMode", 2); //$$ per trade
SetOption("CommissionAmount", 0);
SetOption("MarginRequirement", 10);
SetOption("UsePrevBarEquityForPosSizing", True);
SetOption("UseCustomBacktestProc", True );

SetTradeDelays( 0, 0, 0, 0 );

/*==============================================================================
User-defined Functions
==============================================================================*/
function Support(p)
{
sup = LLV(Low, p);
sup[0] = Low[0];
p = Min(p,BarCount);
for (i = 1; i < p; i++)
{
if(Low < sup[i-1]) sup = Low;
else sup = sup[i-1];
}
return sup;
}

function Resistance(p)
{
res = HHV(High, p);
res[0] = High[0];
p = Min(p,BarCount);
for (i = 1; i < p; i++)
{
if(High > res[i-1]) res = High;
else res = res[i-1];
}
return res;
}

function OptimizeNot(a1, a2, a3, a4, a5)
{
return a2;
}

/*==============================================================================
Entry and Exit Rules
==============================================================================*/
fast = Optimize("Fast", 20, 5, 105, 5);
slow = Optimize("Slow", 140, 20, 420, 20);
FastRes = Resistance(fast);
FastSup = Support(fast);
SlowRes = Resistance(slow);
SlowSup = Support(slow);
heat = 0.05;

// determine longer term trend
// Note: could have problem if current bar is outside of all previous bars
// the trend can also be calculated within main loop, but put here for clarity
trend[0] = 0;
for(bar= 1; bar < BarCount; bar++) // bar must start from 1, otherwise trend calculation is wrong
{
if(High[bar] > SlowRes[bar-1]) trend[bar] = 1;
else if(Low[bar] < SlowSup[bar-1]) trend[bar] = -1;
else trend[bar] = trend[bar-1];
}

LastPosition = 0; // 1 - long; -1 - short
PositionRiskStop = 0;

Buy = Sell = Short = Cover = 0; // this has to be set otherwise they are undefined!!! weird
// main loop
for(bar = 5; bar < BarCount-1; bar++) // give some bars for the system to stablize
{
// Exit position by protection stop
if(LastPosition == 1)
{
// Sell at stop
if(PositionRiskStop > Low[bar] ) // skip if the signal price only touch (=) the low
{
// We just calculate the exact price to simulate Ed's skid
stopPrice = PositionRiskStop;
ff = Min(Open[bar], stopPrice) - Low[bar];
stopPrice = Min(Open[bar], stopPrice) - 0.5*ff;
Sell[bar] = 1;
SellPrice[bar] = stopPrice;
TradePrice[bar] = stopPrice;
LastPosition = 0;
}
else // move the protection stop
{
PositionRiskStop = FastSup[bar];
}
}
else if(LastPosition == -1)
{
// Cover at stop
if(PositionRiskStop < High[bar]) // skip if the signal price only touch (=) the high
{
stopPrice = PositionRiskStop;
ff = High[bar] - Max(Open[bar], stopPrice);
stopPrice = Max(Open[bar], stopPrice) + 0.5*ff;
Cover[bar] = 1;
CoverPrice[bar] = stopPrice;
TradePrice[bar] = stopPrice;
LastPosition = 0;
}
else // move the protection stop
{
PositionRiskStop = FastRes[bar];
}
}
// Enter position only when last position has been closed
else {
if(trend[bar-1] == 1)
{
// buy at stop
if( fastRes[bar-1] < High[bar])
{
ff = High[bar] - Max(Open[bar], FastRes[bar-1]);
stopPrice = Max(Open[bar], FastRes[bar-1]) + 0.5*ff;
f = heat/(FastRes[bar-1] - FastSup[bar-1]);
Buy[bar] = 1;
BuyPrice[bar] = stopPrice;
PositionSize[bar] = f; //this value is passed to CBT for position sizing
LastPosition = 1;
PositionRiskStop = FastSup[bar];
TradePrice[bar] = stopPrice;
}
}
else if(trend[bar-1] == -1)
{
// short at stop
if( FastSup[bar-1] > Low[bar])
{
ff = Min(Open[bar], FastSup[bar-1]) - Low[bar];
stopPrice = Min(Open[bar], FastSup[bar-1]) - 0.5*ff;
f = heat/(FastRes[bar-1] - FastSup[bar-1]);
Short[bar] = 1;
ShortPrice[bar] = stopPrice;
PositionSize[bar] = f; //this value is passed to CBT for position sizing
LastPosition = -1;
PositionRiskStop = FastRes[bar];
TradePrice[bar] = stopPrice;
}
}
}
}

// close final day for accounting purpose
bar = BarCount-1;
if(LastPosition == 1) { Sell[bar] = 1; SellPrice[bar] = (Low[bar]+Close[bar])/2; }
else if(LastPosition == -1) { Cover[bar] = 1; CoverPrice[bar] = (High[bar]+Close[bar])/2; }

/*==============================================================================
Automatic Analysis Action Options
==============================================================================*/
AAAction = Status("action");
if(AAAction == actionIndicator)
{
Plot(FastRes, "FastRes", colorRed);
Plot(SlowRes, "SlowRes", colorPink);
Plot(FastSup, "FastSup", colorGreen);
Plot(SlowSup, "SlowSup", colorBlue);
}
else if(AAAction == actionExplore)
{
Filter = 1;
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn(O, "Open");
AddColumn(H, "High");
AddColumn(L, "Low");
AddColumn(C, "Close");
AddColumn(FastRes, "FastRes");
AddColumn(SlowRes, "SlowRes");
AddColumn(FastSup, "FastSup");
AddColumn(SlowSup, "SlowSup");
AddColumn(Trend, "Trend");
AddColumn(IIf(Buy, Asc("B"), IIf(Sell, Asc("S"), IIf(Short, Asc("H"), IIf(Cover, Asc("C"), 0)))) , "Signal", formatChar);
AddColumn(TradePrice, "TradePrice");
}
else if(AAAction == actionPortfolio)
{
bo = GetBacktesterObject();
bo.PreProcess(); // Initialize backtester
for( bar=0; bar < BarCount; bar++)
{
eq = bo.Equity;
for ( sig=bo.GetFirstSignal(bar); sig; sig=bo.GetNextSignal(bar) )
{
if (sig.isExit())
{
if(bo.ExitTrade(bar,sig.symbol,sig.Price))
{
_TRACE("EXIT: " + sig.symbol + "@" + sig.Price);
}
}
}

// update stats after closing trades
bo.UpdateStats(bar, 1 );

for ( sig=bo.GetFirstSignal(bar); sig; sig=bo.GetNextSignal(bar))
{
if (sig.isEntry())
{
// sig.PosSize is passed from Phase I.
shares = round((eq*sig.PosSize)/100)*100;
ps = shares * sig.Price;

if(bo.EnterTrade(bar, sig.symbol, sig.IsLong, sig.Price, ps, sig.PosScore,sig.RoundLotSize))
{
_TRACE("ENTRY: " + sig.symbol + " @" + sig.Price + " PosScore=" + sig.PosScore + " PosSize=" + ps);
}
}
}

bo.UpdateStats(bar,1); // MAE/MFE is updated when timeinbar is set to 1.
bo.UpdateStats(bar,2);
}
bo.PostProcess(); // Finalize backtester
}
/*==============================================================================
End of Formula
==============================================================================*/
_SECTION_END();
 

Similar threads