EasyLanguage Daily Profit and Daily Loss limit in strategy - EasyLanguage Programming | futures io social day trading
futures io futures trading


EasyLanguage Daily Profit and Daily Loss limit in strategy
Updated: Views / Replies:14,281 / 11
Created: by Big Mike Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 1  
 
Thread Tools Search this Thread
 

EasyLanguage Daily Profit and Daily Loss limit in strategy

  #1 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,231 received

EasyLanguage Daily Profit and Daily Loss limit in strategy

I needed this for my own strategies, so I wanted to share it here.

This will allow a dollar limit of daily loss and daily profit targets, whereby if one or the other is hit then the strategy will stop for the day.

If you wanted to make it weekly, it wouldn't be hard to do. The input for daily loss should be a + value (ie: "250" means a loss of 250, don't use "-250").

 
Code
                            
// for use in signal
inputs:
dailyprofit(500),
dailyloss(250);

vars:
todaynet(0),
yesterdaynet(0);

if 
date <> date[1then begin
yesterdaynet 
NetProfit;
end;

if 
MarketPosition 0 then begin
todaynet 
NetProfit yesterdaynet;
end;

condition1 = -dailyloss todaynet and todaynet dailyprofit;

// entries

if condition 1 then begin
// put your long and short code here
end
Condition1 evaluates to true if the profit for today is between the max loss and max profit. It evaluates to false if one or the other is exceeded. So place your entry code (buy/sellshort) inside the if block.

Let me know if it proves useful!

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following 8 users say Thank You to Big Mike for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Trading Apprentice
Port St Lucie, FL
 
Futures Experience: Intermediate
Platform: Tradestation, MultiCharts
Broker/Data: TradeStation/Open e-cry
Favorite Futures: ES
 
Ranger's Avatar
 
Posts: 46 since Jan 2010
Thanks: 9 given, 43 received


Here's a variation of your signal BM; perhaps others may find this useful too.


RANGER

Attached Files
Register to download File Type: txt Net Profit and Time Limit Code Snippet(Signal).txt (2.0 KB, 313 views)

Last edited by Ranger; March 26th, 2010 at 09:58 AM. Reason: {modified initial posting because of code formatting}
Reply With Quote
The following 4 users say Thank You to Ranger for this post:
 
  #4 (permalink)
Trading Apprentice
vienna
 
Futures Experience: Master
Platform: MultiCharts
Favorite Futures: NQ
 
Posts: 22 since Aug 2009
Thanks: 0 given, 37 received

This is the strategy template from the TS wiki, maybe it is useful for someone who wants to add some code lines to their straregy

 
Code
// EasyLanguageTemplate  [ Strategy ] 
 
// Just select features from the Template 
// that you need for your strategy 
// delete the ones you do not need. 
 
 
[ IntraBarOrderGeneration = False ]; 
// True = Enables Entries or Exits  
// on every Tick during the bar 
// Much more complex coding 
// If using IOG then Backtesting  
// must have Look Inside Bar Testing 
// activated to be approximately accurate 
 
[ BaseCurrency = Account ]; 
// Can ONLY be put on Forex Symbol  
// Give an error on non Forex symbols 
// Forces account currency to be  
// the default for reports, etc. 
 
//[ SameTickOpt = True ]; 
// Can ONLY be put on Indicators 
// Forces a change in price by one tick 
// before TS will process code 
 
//[ InfiniteLoopDetect = False ]; 
// Forces Loop Detection OFF 
 
[ LegacyColorValue = True ]; 
// True = Old EL Colors as default 
// False = New RGB Colors as default 
 
 
 
Inputs: 
    SMAFLength(18), 
    SMASLength(34), 
    StartTime(945), 
    EndTime(1145), 
    LTrailingTicks(0), 
    STrailingTicks(0); 
 
 
Variables: 
    //{ Setup Variables For Inputs } 
    vSMAFLength(0), 
    vSMASLength(0), 
    vStartTime(0), 
    vEndTime(0), 
    vLTrailingTicks(0), 
    vSTrailingTicks(0), 
 
    Price    ( "" ), 
    Decimals( 0 ), 
 
    { Daily NetProfits } 
    vNetProfit(0), 
    vDailyNetProfit(0), 
 
 
    { Calculation Variables } 
    IntraBarPersist SMAFast(0), 
    IntraBarPersist SMASlow(0), 
 
    { Trade High & Low } 
    IntraBarPersist TLHigh(0), 
    IntraBarPersist TLLow(0), 
 
    { Daily High, Low, Open & Close when using IntraDay Charts } 
    IntraBarPersist PriorDayHigh(0), 
    IntraBarPersist PriorDayLow(0), 
    IntraBarPersist PriorDayOpen(0), 
    IntraBarPersist PriorDayClose(0), 
    IntraBarPersist TodayOpen(0), 
    IntraBarPersist TodayHigh(0), 
    IntraBarPersist TodayLow(0), 
 
    { Weekly High & Weekly Low when using IntraDay Charts } 
    IntraBarPersist WeekHigh(0), 
    IntraBarPersist WeekLow(0), 
 
    { Monthly High & Monthly Low when using IntraDay Charts } 
    IntraBarPersist MonthHigh(0), 
    IntraBarPersist MonthLow(0), 
 
    { TradeStation Variables } 
    IntraBarPersist MP(0),            // MarketPosition 
    IntraBarPersist MP1(0),             // Prior Tick MarketPosition 
    IntraBarPersist PP(0),            // PositionProfit 
    IntraBarPersist BSE(0),            // BarsSinceEntry 
    IntraBarPersist BSExit(0),          // BarsSinceExit 
    IntraBarPersist BarsLastExit(0), 
    IntraBarPersist CC(0),            // CurrentContracts 
    IntraBarPersist CC1(0),             // Prior Tick CurrentContracts 
    IntraBarPersist PPPC(0),        // PositionProfit Per Contract     
    IntraBarPersist PPPE(0),        // PositionProfit Per Entry     
    IntraBarPersist CE(0),        // CurrentEntries 
    IntraBarPersist EP(0),            // EntryPrice 
    IntraBarPersist AEP(0),            // Average Entry Price 
    IntraBarPersist vBarNumber(0),      // BarNumber 
    IntraBarPersist LastBar(False),     // LastBarOnChart 
    IntraBarPersist vCategory(0),       // Category 
    IntraBarPersist VCurrentBar(0), 
    IntraBarPersist CE(0),            // CurrentEntries 
    IntraBarPersist PPTotal(0),            // PositionProfit Total 
    OneTick(0), 
    vBarType(0), 
    vBarInterval(0); 
 
 
 
//{ ++++++++++++++++++++++++++++++ } 
//{ +++++++ CurrentBar = 1 +++++++ } 
//{ ++++++++++++++++++++++++++++++ } 
If CurrentBar = 1 then 
begin 
    // Place code here you want processed ONLY on the First Bar of the Chart 
  
    //{ Category Setup } 
    vCategory=Category; 
 
    //{ Decimal Place SetUp by Goose } 
    Price = NumToStr( MinMove/PriceScale, 10 ) ; 
    for Value2 = 1 to 12 
    begin 
            if RightStr( Price, 1 ) = "0" then 
        Price = LeftStr( Price, StrLen( Price ) - 1 ) 
    else 
        Value2 = 12 ;       // stop loop when zero not found 
    end ; 
 
    Decimals = StrLen(Price) -2 ;    // subtract 2 for decimals 
 
    { One Tick } 
    OneTick = MinMove / PriceScale; 
 
    //{ Order Entry Routing SetUp For Stocks } 
    If vCategory = 2 then SetRouteName("ARCX"); 
 
 
    //{ BarType - // 0=tick 1=IntraDay 2=Daily 3=Weekly 4=Monthly } 
    vBarType=BarType; 
    vBarInterval=BarInterval; 
 
    //{ Store Inputs into Variables - reduced CPU load } 
    vSMAFLength     = SMAFLength; 
    vSMASLength     = SMASLength; 
    vStartTime         = StartTime; 
    vEndTime         = EndTime; 
    vLTrailingTicks = LTrailingTicks; 
    vSTrailingTicks = STrailingTicks; 
 
end; 
 
 
//{ +++++++++++++++++++++++++++++++ } 
//{ ++++ TradeStation Variables +++ } 
//{ +++++++++++++++++++++++++++++++ } 
//{ Get TradeStation Variables - use commands one time only to reduce CPU load} 
LastBar = LastBarOnChart; 
MP1 = MP;            // Prior Tick MarketPosition 
MP = MarketPosition; 
EP = EntryPrice; 
AEP= AvgEntryPrice; 
PP = PositionProfit; 
CC1 = CC;            // Prior Tick CurrentContracts  
CC = CurrentContracts; 
CE = CurrentEntries; 
If CurrentBar = 1 then 
    vBarNumber = 1 
else 
    vBarNumber = vBarNumber[1] + 1; 
 
{ TICK level BarsSinceEntry WorkAround } 
// TradeStation BarsSinceEntry Command is  
// Inaccurate with Stop & Reverse Entries  
// or Scaling In Trades 
// This workaround is always correct 
 
If (MP <> 0 and MP1 = 0)          // This tick in a Trade & Prior tick was Flat 
        or (MP = 1 and MP1 = -1)  // This tick in a LONG Trade & Prior tick was SHORT Trade 
        or (MP = -1 and MP1 = 1)  // This tick in a SHORT Trade & Prior tick was LONG Trade 
        or (CC > CC1)             // Another Entry in the same direction 
        then 
   BSE = 0 
else 
If BarStatus(1) = 2 and MP <> 0 then        // Increase BarSinceEntry Counter at End of Bar only 
    BSE = BSE + 1 
else 
If MP = 0 and MP1 <> 0 then     // This Tick no trade & last tick was in a trade 
    BSE = -999; 
 
{ or - Bar Level BarsSinceEntry WorkAround } 
If (MP <> 0 and MP[1] = 0)       // Current Bar in a Trade, Prior Bar Flat 
or (MP = 1 and MP[1] = -1)       // Current Bar Long, Prior bar Short   
or (MP = -1 and MP[1] = 1)       // Current Bar Short, Prior bar Long 
or CC > CC[1] then               // Scaling In Trade 
begin 
   BSE = 0; 
end 
else 
If MP <> 0 
begin 
   BSE = BSE[1] + 1; 
end 
else  
If MP = 0 then 
begin 
   BSE = -999; 
end; 
 
 
{ BarsSinceExit WorkAround - Bar Level } 
// TradeStation BarsSinceExit Command is Inaccurate with Stop & Reverse Entries and Scaling-In Multiple Entries 
If MP <> 0 then 
begin 
    BarsLastExit = 0; 
end 
else 
If BarsSinceExit(1) = 0 or (MP = 0 and MP[1] <> 0) then 
begin 
    BarsLastExit = BarsLastExit[1] + 1; 
end; 
 
 
{ BarsSinceExit WorkAround - Tick Level } 
// TradeStation BarsSinceExit Command is Inaccurate with Stop & Reverse Entries and Scaling-In Multiple Entries 
 
MP1 = MP; 
MP  = MarketPosition; 
CC1 = CC; 
CC  = CurrentContracts; 
 
If (MP = 0 and MP[1] <> 0)    // This tick bar Flat and Prior tick was in a Trade 
        or CC < CC1           // this tick less contracts  
begin 
    BSExit = 0;   // New Exit Just Occurred this bar set BSExit Variable 
                   // Place any code here you want executed on same bar as exit occurred 
end 
else 
If BarStatus(1) = 2 then  
begin 
    BSExit = BSExit[1] + 1;   // Increase BSExit bar counter for number of bars since last exit occurred 
end; 
 
 
{ BarStatus(1) = 0 WorkAround } 
// Code donated by Goose 
// To process code on the First Tick of a Bar BarStatus(1) = 0 is problematic 
// This workaround provides a reliable solution 
 
 
[IntrabarOrderGeneration = True] 
 
Variables: 
    IntrabarPersist Bar_Number( 0 ) ; 
 
if Bar_Number <> CurrentBar then 
begin 
    Bar_Number = CurrentBar ; 
    // Put code here you want processed on first tick of a bar 
end ; 
 
 
{ Position Profit Per Contract & Per Entry } 
If CE > 0 and CC > 0 then 
begin 
    { PPTotal = PositionProfit Total } 
    PPTotal = PP; 
    { PPPC = PositionProfit Per Contract } 
    If PPTotal <> 0 then 
        PPPC = PPTotal / CC; 
    { PPPE = PositionProfit Per Entry } 
    If PPTotal <> 0 then 
        PPPE = PPTotal / CE; 
end; 
 
 
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } 
{ ++++ IntraDay Calculation of Daily High, Low, Open & Close ++++++ } 
{ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } 
If Date <> Date[1] then 
begin 
    PriorDayClose = Close[1]; 
    PriorDayHigh = TodayHigh; 
    PriorDayLow = TodayLow; 
    PriorDayOpen = TodayOpen; 
 
    TodayHigh = High; 
    TodayLow = Low; 
    TodayOpen = Open; 
end 
else 
begin 
    TodayHigh = MaxList( High, TodayHigh ) ; 
    TodayLow  = MinList( Low, TodayLow ) ; 
end; 
 
 
{ +++++++++++++++++++++++++++++++++++++++++++++++ } 
{ +++++ IntraDay Chart - Weekly High & Low ++++++ } 
{ +++++++++++++++++++++++++++++++++++++++++++++++ } 
If DayOfWeek( Date ) < DayOfWeek( Date[1] ) then 
begin 
    WeekHigh = High; 
    WeekLow = Low; 
end 
else 
begin 
    WeekHigh = MaxList( High, WeekHigh ) ; 
    WeekLow  = MinList( Low, WeekLow ) ; 
end; 
 
 
{ +++++++++++++++++++++++++++++++++++++++++++++++ } 
{ +++++ IntraDay Chart - Monthly High & Low ++++++ } 
{ +++++++++++++++++++++++++++++++++++++++++++++++ } 
If Month(Date) <> Month(Date[1]) then 
begin 
    MonthHigh = High; 
    MonthLow = Low; 
end 
else 
begin 
    MonthHigh = MaxList( High, MonthHigh ) ; 
    MonthLow  = MinList( Low, MonthLow ) ; 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Each New Day  ++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++ } 
If Date <> Date[1] then 
begin 
    // Place code here you want executed on the first bar of each new day 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Each New Session  ++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++++++ } 
If CurrentSession(0) <> CurrentSession(0)[1] then 
begin 
    // Place code here you want executed on First Bar of each New Session 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Today ONLY  ++++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++ } 
If Date <> Date[1] and Date = CurrentDate then 
begin 
    // Place code here you want executed on First Bar if Today is the Current Date 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Yesterday ONLY  ++++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++++++ } 
If Date <> Date[1] and Date = CurrentDate - 1 then 
begin 
    // Place code here you want executed on First Bar Of Yesterday ONLY 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Each New Week  +++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++++ } 
If (( vCategory = 2 and Date <> Date[1] ) 
    or ( vCategory <> 2 and CurrentSession(0) <> CurrentSession(0)[1] ) ) 
    and ( ( vCategory = 2 and DayOfWeek(Date) = 1 ) 
    or ( vCategory <> 2 and DayOfWeek(Date) = 0 ) ) then 
begin 
    // Place code here you want executed of First Bar of each New Week 
end; 
 
 
//{ ++++++++++++++++++++++++++++++++++++++++ } 
//{ ++++ First Bar of Each New Month  ++++++ } 
//{ ++++++++++++++++++++++++++++++++++++++++ } 
If Month(Date) <> Month(Date[1]) then 
begin 
    // Place code here you want executed of First Bar of each New Month 
end; 
 
 
{ ++++++++++++++++++++++++++++++++++++++++++++++++++ } 
{ ++++++++++  First Bar of MONDAY Only  ++++++++++++ } 
{ ++++++++++++++++++++++++++++++++++++++++++++++++++ } 
// For this example if you wanted to execute code on the first bar of Monday Opening Bar ONLY 
// 0 = Sunday, 1=Monday, 2=Tuesday, etc. 
 
If DayOfWeek(Date) = 1 and Date <> Date[1] then 
begin 
    // Put code here to execute on First Bar of every Monday 
end; 
 
 
 
//{ +++++++++++++++++++++++++++++++++++ } 
//{ ++++ New Trade High & Low   +++++++ } 
//{ +++++++++++++++++++++++++++++++++++ } 
If (MP <> 0 and MP[1] = 0)                       // In Trade This Bar and Prior Bar Was Flat 
    or (MP = 1 and MP[1] = -1 )     // In SHORT Trade This Bar and Prior Bar was LONG Trade 
    or (MP = -1 and MP[1] = 1 )  then   // In LONG Trade This Bar and Prior Bar was SHORT Trade 
begin 
    { First Bar of a New Trade } 
    TLHigh = High; 
    TLLow = Low; 
end 
else 
{ Still in Trade so Track Trade High & Trade Low } 
If MP <> 0 then 
begin 
    TLHigh = MaxList( High, TLHigh ) ; 
    TLLow =  MinList( Low, TLLow ) ; 
end 
else 
{ Flat - Reset Variables } 
If MP = 0 then 
begin 
    TLHigh = 0; 
    TLLow = 9999; 
end; 
 
 
//{ +++++++++++++++++++++++++++++++++++++++ } 
//{ ++++++ Calculations Section  ++++++++++ } 
//{ +++++++++++++++++++++++++++++++++++++++ } 
If Barstatus(1) = 2 then 
begin 
    // Place calculations here you only want to run once per bar at the end of each bar 
 
    // IntraDay Chart Calculation of Daily NetProfit 
    // Strategy Code 
    // Can use this to calculate Daily NetProfit 
    // One use is to stop trading if hit a given daily Profit Objective or Loss Amount 
    If Date = CurrentDate and Date <> Date[1] then 
    begin 
        vNetProfit = NetProfit; 
    end 
    else 
    If Date = CurrentDate then 
    begin 
        { Calculate Daily NetProfits } 
        vDailyNetProfit = NetProfit - vNetProfit; 
    end; 
 
    { Calculations } 
    SMAFast = Average(Close,vSMAFLength); 
    SMASlow = Average(Close,vSMASLength); 
 
end; 
 
 
//{ +++++++++++++++++++++ } 
//{ +++ Entries +++++++++ } 
//{ +++++++++++++++++++++ } 
If Time >= vStartTime and Time < vEndTime then 
begin 
    //{ Order Routing SetUp For Stocks } 
    If vCategory = 2 then 
        SetRouteName("ARCX"); 
 
    //{ LONG Initial Entry } 
    If SMAFast crosses above SMASlow then 
         Buy ("L-SMA-X") next bar at market; 
 
    //{ SHORT Initial Entry } 
    If SMASlow crosses under SMASlow then 
        SellShort ("S-SMA-X") next bar at market; 
 
end;     // If BarStatus(1) = 2 then 
 
 
//{ +++++++++++++ } 
//{ ++ Exits ++++ } 
//{ +++++++++++++ } 
If MP <> 0 then 
begin 
    //{ Order Routing SetUp for Stocks } 
    If vCategory = 2 then 
        SetRouteName("ARCX"); 
 
    // Exits Here 
 
    If MP = 1 and Close < TLHigh - (vLTrailingTicks * OneTick) then 
        Sell ("LX-Trailing") next bar at market; 
 
    If MP = -1 and Close > TLLow + (vSTrailingTicks * OneTick) then 
        BuyToCover ("SX-Trailing") next bar at market; 
 
 
end;    // If MP <> 0 then

Reply With Quote
The following 2 users say Thank You to insideday for this post:
 
  #5 (permalink)
Elite Member
copenhagen, denmark
 
Futures Experience: Intermediate
Platform: multicharts, Ninja
Broker/Data: IB & Kinetick
Favorite Futures: ES
 
mengelbrecht's Avatar
 
Posts: 47 since Aug 2010
Thanks: 16 given, 21 received

Help needed


Big Mike View Post
I needed this for my own strategies, so I wanted to share it here.

This will allow a dollar limit of daily loss and daily profit targets, whereby if one or the other is hit then the strategy will stop for the day.

If you wanted to make it weekly, it wouldn't be hard to do. The input for daily loss should be a + value (ie: "250" means a loss of 250, don't use "-250").

 
Code
                            
// for use in signal
inputs:
dailyprofit(500),
dailyloss(250);

vars:
todaynet(0),
yesterdaynet(0);

if 
date <> date[1then begin
yesterdaynet 
NetProfit;
end;

if 
MarketPosition 0 then begin
todaynet 
NetProfit yesterdaynet;
end;

condition1 = -dailyloss todaynet and todaynet dailyprofit;

// entries

if condition 1 then begin
// put your long and short code here
end
Condition1 evaluates to true if the profit for today is between the max loss and max profit. It evaluates to false if one or the other is exceeded. So place your entry code (buy/sellshort) inside the if block.

Let me know if it proves useful!

Mike


H
I everyone
I am trying to implement a daily profit/ loss limit in my trading strategy. To understand exactly what is going on I implemented Big Mike Code in a simple MACD cross over, prior to implementing it my "production trading code" - .
For some reason the code below doesn't work, and don't understand why it isn't working
What I am trying to achieve is very simple; - I want the trading to stop IF dailyprofit or dailyloss is reached within the specified timeframe.

What am i missing ??

Rgds Mengelbrecht


Multicharts - Code:
inputs:
FastLength( 12 ),
SlowLength( 26 ),
MACDLength( 9 ),
starttrade (0800),
endtrade(1600),
dailyprofit(500),
dailyloss(250);


Variables:
todaynet(0),
yesterdaynet(0),
var0( 0 ),
var1( 0 ),
var2( 0 ) ;

var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;

if date <> date[1] then begin
yesterdaynet = NetProfit;
end;


todaynet = NetProfit + openpositionprofit - yesterdaynet;

condition1 = var2 crosses under 0 ;
condition2 = var2 crosses over 0 ;

condition98 = (-dailyloss < todaynet and todaynet < dailyprofit) and (Time > starttrade and time < endtrade);


if condition98 then begin
if condition1 then sellshort ( "MacdSE" ) next bar at market;
if condition2 then buy ( "MacdLE" ) next bar at market ;
end;

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Toronto, Canada
 
Futures Experience: Beginner
Platform: Multicharts
Favorite Futures: EUR/USD
 
Posts: 1 since Jan 2015
Thanks: 0 given, 0 received

Daily stop loss/profit target revisited

Hi Mengelbrecht and all:

I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.

In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.

If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?

Thanks!

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,529 since Apr 2013
Thanks: 230 given, 854 received
Forum Reputation: Legendary

volatilius,

post your code and I am sure someone here in the forum can point you in the right direction.

Regards,

ABCTG


volatilius View Post
Hi Mengelbrecht and all:

I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.

In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.

If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?

Thanks!


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #8 (permalink)
Elite Member
copenhagen, denmark
 
Futures Experience: Intermediate
Platform: multicharts, Ninja
Broker/Data: IB & Kinetick
Favorite Futures: ES
 
mengelbrecht's Avatar
 
Posts: 47 since Aug 2010
Thanks: 16 given, 21 received


volatilius View Post
Hi Mengelbrecht and all:

I am trying to set up an automated strategy involving a daily stop loss/profit target in Easy Language. I was browsing the forum for any answers and discovered Mengelbrecht encountered the same problem that I am having, in 2010, but I don't know whether the issue was resolved as that's where the thread ends.

In a nutshell, I also wanted to somehow incorporate in the code, a mechanism to terminate a current position if its profit/loss makes the daily profit/loss reach the target. I independently wrote an almost identical code as the code posted by Mengelbrecht, but also put [Intrabarordergeneration=true], and declared some variables as "intrabarpersist". Still, it didn't work.

If that issue has been resolved, could someone please post a working code that is taking into account any current position (the code should be probably using "positionprofit") and terminates that position when the daily profit/loss is reached?

Thanks!

Hi volatilius
sorry for the late respons, I have been away from my desk all weekend.
This is code that someone send me:

inputs: dailyprofit(300),dailyloss(300);

variables: todaynet(0), yesterdaynet(0), priordate (date) ;


once
begin
priordate = Date - 1;
end;

if date > priordate then begin
priordate = date;
yesterdaynet = NetProfit;
end;

todaynet = NetProfit + openpositionprofit - commission – yesterdaynet;

You need to integrate this into the strategy that you have developed

Have fun
Rgds
Mengelbrecht

Reply With Quote
The following user says Thank You to mengelbrecht for this post:
 
  #9 (permalink)
Trading Apprentice
Chicago
 
Futures Experience: Master
Platform: MuktiCharts
Favorite Futures: Gold
 
Posts: 4 since Apr 2013
Thanks: 3 given, 0 received

Variation to this code

Hello Mike,

How can this code be modified to set a profit objective for the day that acts as a profit stop? For example the profit breaches a $200 profit level and keeps trading unless the profit falls back below $200 in the same day. Any ideas?

Reply With Quote
 
  #10 (permalink)
Trading Apprentice
Prague
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES
 
Posts: 2 since Nov 2013
Thanks: 1 given, 0 received

Yesteraday profit


Hi,

is there way to get yesterday Netprofit to compare with todays Netprofit please?

Reply With Quote

Reply



futures io > > > > > EasyLanguage Daily Profit and Daily Loss limit in strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Daily Loss Limit togier NinjaTrader Programming 11 February 4th, 2017 08:24 PM
When a stop loss order is filled beyond limit price Big Mike Reviews of Brokers and Data Feeds 56 September 15th, 2015 10:01 AM
Daily Loss Limit sleepy Reviews of Brokers and Data Feeds 18 August 20th, 2014 03:53 PM
Daily Trade Reconciliation Strategy MXASJ The Elite Circle 27 December 9th, 2010 09:12 PM
Working on profit-loss ratio cclsys NinjaTrader Programming 39 December 1st, 2009 11:32 PM


All times are GMT -4. The time now is 09:28 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.23 seconds with 20 queries on phoenix via your IP 54.82.56.95