NexusFi: Find Your Edge


Home Menu

 





MultiCharts MACD exit strategy


Discussion in MultiCharts

Updated
    1. trending_up 4,135 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
bam2809
Cleveland Ohio
 
Posts: 1 since Sep 2013
Thanks Given: 1
Thanks Received: 0

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!


Reply With Quote

 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
The Pivot Point 113.6³ — Navigating the Prediction of …
26 thanks
Sober Journey With S&P
16 thanks
The Confluence Meter: A Multi-Layered Signal Framework B …
11 thanks
NT8 color choices
10 thanks
Volume Indicators
7 thanks
  #2 (permalink)
 ehlaban 
Netherlands
 
Experience: Advanced
Platform: Ensign, Multicharts
Trading: SP500
Posts: 91 since Nov 2009
Thanks Given: 66
Thanks Received: 57

didn't check the code in MC but just a first look,

didn't you forget and end; statement as there are 3 begins and 2 end; ???


Reply With Quote
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639


Hi bam2809,

why do you do you place
 
Code
       SetStopContract;
	SetStopLoss (300);
	SetProfitTarget (10);
inside your condition checks? I must admit that I don't exactly understand what you are trying to do, but
if you use one instance of
 
Code
       SetStopContract;
	SetStopLoss (300);
	SetProfitTarget (10);
at the end of your code for example, MC should take care of the proper order management by itself.

Regards,
ABCTG


bam2809 View Post
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!


Follow me on X Reply With Quote
Thanked by:




Last Updated on October 4, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts