Code: Select all
Input: OpenPrice(100), value1(0.5),Interval(0.5);
Vars: value2(0),
LoopEntryPrice1(0),
LoopEntryPrice2(0),
LoopEntryPrice3(0),
LoopEntryPrice4(0),
LoopEntryPrice5(0),
LoopEntryPrice6(0),
LoopEntryPrice7(0),
LoopEntryPrice8(0),
LoopEntryPrice9(0),
LoopEntryPrice10(0);
LoopEntryPrice1 = OpenPrice + Interval*0;
LoopEntryPrice2 = OpenPrice + Interval*1;
LoopEntryPrice3 = OpenPrice + Interval*2;
LoopEntryPrice4 = OpenPrice + Interval*3;
LoopEntryPrice5 = OpenPrice + Interval*4;
LoopEntryPrice6 = OpenPrice + Interval*5;
LoopEntryPrice7 = OpenPrice + Interval*6;
LoopEntryPrice8 = OpenPrice + Interval*7;
LoopEntryPrice9 = OpenPrice + Interval*8;
LoopEntryPrice10 = OpenPrice + Interval*9;
if close > LoopEntryPrice1 then
Buy("Buy1") next bar at LoopEntryPrice1 limit;
if close > LoopEntryPrice2 then
Buy("Buy2") next bar at LoopEntryPrice2 limit;
if close > LoopEntryPrice3 then
Buy("Buy3") next bar at LoopEntryPrice3 limit;
if close > LoopEntryPrice4 then
Buy("Buy4") next bar at LoopEntryPrice4 limit;
if close > LoopEntryPrice5 then
Buy("Buy5") next bar at LoopEntryPrice5 limit;
if close > LoopEntryPrice6 then
Buy("Buy6") next bar at LoopEntryPrice6 limit;
if close > LoopEntryPrice7 then
Buy("Buy7") next bar at LoopEntryPrice7 limit;
if close > LoopEntryPrice8 then
Buy("Buy8") next bar at LoopEntryPrice8 limit;
if close > LoopEntryPrice9 then
Buy("Buy9") next bar at LoopEntryPrice9 limit;
if close > LoopEntryPrice10 then
Buy("Buy10") next bar at LoopEntryPrice10 limit;
setstopshare;
setprofittarget_pt(value1*1000);
Hi, I wrote a code of repeat trading system as above.
I modified the code as bellow simply, but it does not work.
After I take one position, I cannot take the next position because of the same order without "allowing in the same direction as the currently held position" mode.
If I change it to "allowing up to 10 entry orders in the same direction as the currently held position" mode, I entered many times with the same value.
Can anyone tell me?
Thank you
Code: Select all
Input: OpenPrice(100), value1(0.5),odds(100), Interval(0.5);
Vars: ii(0),
LoopEntryPriceLL(0),LoopEntryPriceLS(0);
For ii = 0 to 100 begin
if close > OpenPrice + Interval*ii and close < OpenPrice + Interval*(ii+1) then
LoopEntryPriceLL = OpenPrice + Interval*ii;
LoopEntryPriceLS = OpenPrice + Interval*(ii+1);
end;
buy next bar at LoopEntryPriceLL limit;
buy next bar at LoopEntryPriceLS stop;
setstopposition;
setprofittarget(value1*10000);