NexusFi: Find Your Edge


Home Menu

 





Multiple limit order over several bars


Discussion in EasyLanguage Programming

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




 
Search this Thread

Multiple limit order over several bars

  #1 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1

Hi
I have this code that looks for a certain criteria, then it's allowed to take a long entries within 40 bars after the criteria. I want all my orders to be limit orders for the entries, the way it works now is that it enters at the first bar where it finds some of the values from some of the limit orders, then it doesn't take any new limit orders on later bars (even though it's still within the 40 bars) when the price goes lower to my values. So my question is, can I get it to take multiple limit orders over several bars before it starts to sell?

 
Code
inputs: 
    Price(Low), 
    LeftStrength(2), 
    RightStrength(2), 
    ActivationThresholdDollars(150), 
    TrailingStopDollars(50), 
    EntryWindow(40), 
    StopLossDollars(2500), 
    StartTime(0100), 
    EndTime(1730), 
    EntryPercentageBelowPivotLow1(0.0002), 
    EntryPercentageBelowPivotLow2(0.0004), 
    EntryPercentageBelowPivotLow3(0.0006), 
    EntryPercentageBelowPivotLow4(0.0008), 
    EntryPercentageBelowPivotLow5(0.001), 
    EntryPercentageAbovePivotLow1(0.0002), 
    EntryPercentageAbovePivotLow2(0.0004), 
    EntryPercentageAbovePivotLow3(0.0006), 
    EntryPercentageAbovePivotLow4(0.0008), 
    EntryPercentageAbovePivotLow5(0.001), 
    ProfitTarget1(100), 
    ProfitTarget2(105), 
    ProfitTarget3(115), 
    ProfitTarget4(120), 
    ProfitTarget5(130), 
    ProfitTarget6(140), 
    ProfitTarget7(150), 
    ProfitTarget8(160), 
    ProfitTarget9(170), 
    ProfitTarget10(180); 
 
variables: 
    intrabarpersist double OnePriceTick(0), 
    int LastPivotLowBar(0), 
    double RSIValue(0), 
    bool PivotLowSignal(false), 
    double TrailingStopPrice(0), 
    bool TrailingStopActive(false), 
    int BarCounter(0), 
    bool EntryWindowActive(false), 
    double EntryPrice1(0), 
    double EntryPrice2(0), 
    double EntryPrice3(0), 
    double EntryPrice4(0), 
    double EntryPrice5(0), 
    double EntryPrice6(0), 
    double EntryPrice7(0), 
    double EntryPrice8(0), 
    double EntryPrice9(0), 
    double EntryPrice10(0), 
    double EntryPrice11(0), 
    double StopPrice(0), 
    int EntryCount(0); 
 
once 
begin 
    OnePriceTick = MinMove / PriceScale; 
end; 
 
if Time >= StartTime and Time <= EndTime then 
begin 
    if PivotLowVSBar(1, Price, LeftStrength, RightStrength, RightStrength + 1) <> -1 then 
    begin 
        LastPivotLowBar = CurrentBar; 
        EntryPrice1 = Low[RightStrength]; 
        EntryPrice2 = Low[RightStrength] * (1 - EntryPercentageBelowPivotLow1); 
        EntryPrice3 = Low[RightStrength] * (1 - EntryPercentageBelowPivotLow2); 
        EntryPrice4 = Low[RightStrength] * (1 - EntryPercentageBelowPivotLow3); 
        EntryPrice5 = Low[RightStrength] * (1 - EntryPercentageBelowPivotLow4); 
        EntryPrice6 = Low[RightStrength] * (1 - EntryPercentageBelowPivotLow5); 
        EntryPrice7 = Low[RightStrength] * (1 + EntryPercentageAbovePivotLow1); 
        EntryPrice8 = Low[RightStrength] * (1 + EntryPercentageAbovePivotLow2); 
        EntryPrice9 = Low[RightStrength] * (1 + EntryPercentageAbovePivotLow3); 
        EntryPrice10 = Low[RightStrength] * (1 + EntryPercentageAbovePivotLow4); 
        EntryPrice11 = Low[RightStrength] * (1 + EntryPercentageAbovePivotLow5); 
 
        if EntryCount < 10 then 
        begin 
            Buy("Long-0.0002") 1 contract next bar at EntryPrice2 limit; 
            Buy("Long-0.0004") 1 contract next bar at EntryPrice3 limit; 
            Buy("Long-0.0006") 1 contract next bar at EntryPrice4 limit; 
            Buy("Long-0.0008") 1 contract next bar at EntryPrice5 limit; 
            Buy("Long-0.0010") 1 contract next bar at EntryPrice6 limit; 
            Buy("Long+0.0002") 1 contract next bar at EntryPrice7 limit; 
            Buy("Long+0.0004") 1 contract next bar at EntryPrice8 limit; 
            Buy("Long+0.0006") 1 contract next bar at EntryPrice9 limit; 
            Buy("Long+0.0008") 1 contract next bar at EntryPrice10 limit; 
            Buy("Long+0.0010") 1 contract next bar at EntryPrice11 limit; 
            EntryCount = EntryCount + 1; 
        end; 
    end; 
end; 
 
if MarketPosition <> 0 then 
begin 
    SetStopLoss(StopLossDollars); 
 
    // Set profit targets for each entry 
    Sell("PT1") 1 contract next bar at EntryPrice2 + ProfitTarget1 * OnePriceTick limit; 
    Sell("PT2") 1 contract next bar at EntryPrice3 + ProfitTarget2 * OnePriceTick limit; 
    Sell("PT3") 1 contract next bar at EntryPrice4 + ProfitTarget3 * OnePriceTick limit; 
    Sell("PT4") 1 contract next bar at EntryPrice5 + ProfitTarget4 * OnePriceTick limit; 
    Sell("PT5") 1 contract next bar at EntryPrice6 + ProfitTarget5 * OnePriceTick limit; 
    Sell("PT6") 1 contract next bar at EntryPrice7 + ProfitTarget6 * OnePriceTick limit; 
    Sell("PT7") 1 contract next bar at EntryPrice8 + ProfitTarget7 * OnePriceTick limit; 
    Sell("PT8") 1 contract next bar at EntryPrice9 + ProfitTarget8 * OnePriceTick limit; 
    Sell("PT9") 1 contract next bar at EntryPrice10 + ProfitTarget9 * OnePriceTick limit; 
    Sell("PT10") 1 contract next bar at EntryPrice11 + ProfitTarget10 * OnePriceTick limit; 
end;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

I think you may be looking at a platform issue, not an EL issue. On your platform, in the settings for your Strategy, look for a way to "Allow up to [ x ] entry orders in the same direction as the currently held position:" NOTE: the quotes are how controlling multiple entries is stated in the "Strategy Properties" when using MultiCharts. I assume the verbiage is similar in other platforms.

Reply With Quote




Last Updated on April 22, 2023


© 2024 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 - Privacy Policy - Downloads - Top
no new posts