I have been trying to work out the exit strategy within my
Multicharts MACD setup.
*******************************************************
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ), myProtfitTarget(1),{Profit Target set at 1 tick}
myStopLoss(30); {30 ticks Stop Loss @ $10/tick/contact}
variables: var0( 0 ), var1( 0 ), var2( 0 ), PT (myProtfitTarget * TickSize {* BigPointValue}), SL (myStopLoss * TickSize {* BigPointValue}), OpenPosPL(0);
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
OpenPosPL = GetPositionOpenPL(GetSymbolName,GetAccountID);
condition1 = var2 crosses over 0;
condition2 = var2 crosses under 0;
if OpenPosPL{marketposition} = 0 then begin
if condition1 then begin
Buy ("
bullish") 1
contract this bar on Close;
//Alert( "Bullish alert" )
//Sell ("Exit l3-c1 Target") 1
Contracts Next Bar At (entryprice + PT) Limit;
//Sell ("Exit l3-c1 Stop") 1 Contracts Next Bar At SL Stop;
SetStopContract;
SetStopLoss (300);
SetProfitTarget (10);
end;
if condition2 then begin
SellShort ("
bearish") 1 contract this bar on Close;
//Alert( "Bearish alert" ) ;
//BuyToCover ("Exit l3-c1 Target") 1 Contracts Next Bar At (entryprice - PT) Limit;
//BuyToCover ("Exit l3-c1 Stop") 1 Contracts Next Bar At SL Stop;
SetStopContract;
SetStopLoss (300);
SetProfitTarget (10);
end;
*************************************
Here I have esablished the for SL $300 and PT $10. I want a way to check and see if I am
flat. "if marketposition = 0 then begin" does not seem to work with "SetStopLoss" and "SetProfitTarget". It recognizes the initial conditions are met places a buy or sell order then the program gets lost. I have tried a variable using "GetPositionOpenPL" instead of "marketposition" in hope to achieve the same info as to whether or not I am flat. It works but the SL and PT an re not consistent and are not placed with every entry......Please help!