I am not a coder but I had my share of trying out and research, so I hope it is ok to bother you guys now.
I want to code a Signal that is managing my trade. The easy stuff is working fine (timing, stopp, profit...), but some core things are just not working. My current problem:
- I want my Limitorder to be cancelled once the level got "tested".
For example:
Limitorder (buy) is at 100, current price is at 150. The price is now dropping to 110, then moving back to 150. My entrylevel is now "tested" and I dont want to trade that level anymore.
I was trying to fix that with variables (see below), but that is not working. Do you have any ideas or is it just a dumb idea that I want to realize this in MC? Thanks a lot in advance!
The "tested level" code:
Code: Select all
Inputs:
L1( 0 ),
MyStopTicks( 30 ),
MyProfitTicks( 30 ),
MyBreakEvenTicks( 10 ),
MyTestedTicks( 5 );
var:
varL1(0),
varL1Test3(0),
varL1Test10(0),
varCountL1(0),
checkit1(0);
varL1 = L1;
varL1Test3 = varL1 +MyTestedTicks;
varL1Test10 = varL1 +MyProfitTicks;
if CurrentAsk <= varL1Test3 then checkit1 = checkit1 +1;
if CurrentAsk >= varL1Test10 and checkit1 > 0 then varCountL1 = varCountL1 +1;
if varL1 > 0 and varCountL1 = 0 then buy("L1") MyContracts contracts next bar varL1 limit;
Code: Select all
[IntrabarOrderGeneration = true];
// IMPORTANT PRE-SETTINGS
Inputs:
FromMonth( 0 ),
FromDay( 0 ),
FromTime( 0 ),
RedNewsStart( 0 ),
MyContracts( 1 );
// LEVELS
Inputs:
L1( 0 ),
L2( 0 ),
S1( 0 ),
S2( 0 );
// TRADE MANAGEMENT
Inputs:
MyStopTicks( 30 ),
MyProfitTicks( 30 ),
MyBreakEvenTicks( 10 ),
MyTestedTicks( 5 );
// OTHER SETTINGS
Inputs:
RedNewsDoNotOpenBefore( 30 ),
RedNewsDoNotOpenAfter( 30 ),
RedNewsCloseAllBefore( 5 );
// VARIABLES
var:
varL1(0),
varL1Test3(0),
varL1Test10(0),
varCountL1(0),
checkit1(0);
// DEFINITIONS
varL1 = L1;
varL1Test3 = varL1 +MyTestedTicks;
varL1Test10 = varL1 +MyProfitTicks;
// CONDITIONING
if Month(date) = FromMonth and dayofmonth(date) >= FromDay and Time >= FromTime then begin
// CODING L1
if CurrentAsk <= varL1Test3 then checkit1 = checkit1 +1;
if CurrentAsk >= varL1Test10 and checkit1 > 0 then varCountL1 = varCountL1 +1;
if varL1 > 0 and varCountL1 = 0 then buy("L1") MyContracts contracts next bar varL1 limit;
setstoploss_pt(MyStopTicks);
setprofittarget_pt(MyProfitTicks);
end;