Register Login
Forums    February 9, 2012
TradersStudio Forums
MaxPositionProfit
Last Post 11-24-2009 06:07 PM by mur ang. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Rina Anderson
New Member
New Member
Posts:4

--
11-23-2009 08:22 PM
    Can I have an example of how to use MaxPositionProfit?

    For example, I would like to exit at the close of a bar if the max position profit is greater than X.

    Here is some code with my attempt:

    Sub MA_CROSS_Exits (SLen As Integer, LLen As Integer, MPTargetLX as Integer, MPTargetSX as Integer)
        Dim ShortAve As BarArray
        Dim LongAve As BarArray
        Dim MPP As BarArray
       
        ShortAve = Average(Close, SLen,0)
        LongAve = Average(Close, LLen,0)
         If Close > LongAve  Then
            Buy("BuyEnt",1,0,Market,Day)
        End If
        If Close < ShortAve  Then
            Sell("SellEnt",1,0,Market,Day)
        End If
      
    'Exit - Trailing Early Profit Target

        MPP = MaxPositionProfit
       
        If MPP > MPTargetLX Then
            ExitShort("eSX","BuyEnt", 1, 0, CloseExit, Day)
            MPP = 0
        End If
        If MPP > MPTargetSX Then
            ExitLong("eLX","SellEnt", 1, 0, CloseExit, Day)
            MPP = 0
        End If
       
    End Sub

    mur ang
    Advanced Member
    Advanced Member
    Posts:525

    --
    11-24-2009 06:07 PM
    If MPP > MPTargetLX Then
            ExitShort("eSX","SellEnt", 1, 0, CloseExit, Day)
            MPP = 0
        End If
        If MPP > MPTargetSX Then
            ExitLong("eLX","BuyEnt", 1, 0, CloseExit, Day)
            MPP = 0
        End If

    you had exitlong exiting the short and exishort exiting the long , try this.
    You are not authorized to post a reply.


     TradersStudio, Inc. ® Copyright 2004-2012 All Rights Reserved   Terms Of Use  Privacy Statement