none
Adjusting the .NET Paroblic_SAR Day-Trading Signal: RRS feed

  • Question

  • I need assistance in adjusting the below trading signal with these needed Changes for the LongEntry:

    ______________________________________________________________________________

    // Long Order Entry:

    If  SAR.Price of 1 Bar ago is Greater Than the HIGH of 1 Bar ago and

    SAR.Price of the Current Bar is less than the LOW of the Current Bar

    Then Buy at VALUE1 with a stop Order

    Value1 = Open.Price of the Current Bar 

     

    // Long Order Exit 

    If the Long entry is active and 

    The SAR.Price of 1 Bar ago is less than the LOW of the Current Bar and 

    The SAR.Price of the Current bar is Greater than the SAR.Price

    Then Exit the current bar at market Price.

    ______________________________________________________

    using System;
    using PowerLanguage.Function;

    namespace PowerLanguage.Strategy
    {
        [IOGMode(IOGMode.Disabled)]
        public class Parabolic_LE : SignalObject
        {
            private ParabolicSAR m_ParabolicSAR;

            private VariableObject<Double> m_oparcl;

            private VariableObject<Double> m_oparop;

            private VariableObject<int> m_Oposition;

            private VariableObject<int> m_otransition;

            private IOrderPriced m_ParLE;

            public Parabolic_LE(object ctx) :
                base(ctx)
            {
                AFLimit = 0.2;
                AFStep = 0.02;
            }

            [Input]
            public double AFStep { get; set; }

            [Input]
            public double AFLimit { get; set; }

            protected override void Create(){
                m_ParabolicSAR = new ParabolicSAR(this);
                m_oparcl = new VariableObject<Double>(this);
                m_oparop = new VariableObject<Double>(this);
                m_Oposition = new VariableObject<int>(this);
                m_otransition = new VariableObject<int>(this);
                m_ParLE = OrderCreator.Stop(new SOrderParameters(Contracts.Default, "ParLE", EOrderAction.Buy));
            }

            protected override void StartCalc(){
                m_ParabolicSAR.afstep = AFStep;
                m_ParabolicSAR.aflimit = AFLimit;
                m_ParabolicSAR.oparcl = m_oparcl;
                m_ParabolicSAR.oparop = m_oparop;
                m_ParabolicSAR.oposition = m_Oposition;
                m_ParabolicSAR.otransition = m_otransition;
            }


            protected override void CalcBar(){
                m_ParabolicSAR.Call();
                if (m_Oposition.Value == -1){
                    m_ParLE.Send(m_oparop.Value);
                }
            }
        }
    }

    Thanks In advance

    Roger H Hicks


    • Edited by HICKSUNLIMITED Sunday, November 5, 2017 12:03 PM issue with elements
    Sunday, November 5, 2017 11:57 AM

Answers

  • Hello HICKUNLIMITED,

    I'm not sure the entity class meaning in your program, according to your description I write some pseudo-code represented the actual meaning of your entity class . The logic should be like below.

     Boolean shortcondition = PreviousBar.SarPrice > bar.Hight;
    
                Boolean LongCondition  = CurrentBar.SarPrice < bar.Low;
    
                if (shortcondition && LongCondition) {
    
                    //Open Price of the Bar to be the entry price at a Stop 
    
                }

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by HICKSUNLIMITED Sunday, December 3, 2017 10:35 AM
    Tuesday, November 14, 2017 2:45 AM
    Moderator

All replies

  • Hello Roger,

    I'm sorry that I don't have much knowledge about trading strategy.  What propose you want to achieve . For a input what result you want to achieve. What the meaning of your customer type in your code.

    Please share more information about your project.

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 6, 2017 10:27 AM
    Moderator
  • This is a Trading Process Parabolic Stop-and-Reverse, this indicator provides both entries and exits. The indicator is composed of a series of dots, either above or below the price. When dots move from below to above the price bars, it is time to get out of longs or get short.

    Calculation

    Calculation of SAR is complex with if/then variables that make it difficult to put in a spreadsheet. These examples will provide a general idea of how SAR is calculated. Because the formulas for rising and falling SAR are different, it is easier to divide the calculation into two parts. The first calculation covers rising SAR and the second covers falling SAR.

    Prior SAR: The SAR value for the previous period.

    Extreme Point (EP): The highest high of the current uptrend.

    Acceleration Factor (AF): Starting at .02, AF increases by .02 each time the extreme point makes a new high. AF can reach a maximum of .20, no matter how long the uptrend extends.

    Current SAR = Prior SAR + Prior AF(Prior EP - Prior SAR)

    13-Apr-10 SAR = 48.28 = 48.13 + .14(49.20 - 48.13)

    The Acceleration Factor is multiplied by the difference between the Extreme Point and the prior period's SAR. This is then added to the prior period's SAR. Note however that SAR can never be above the prior two periods' lows. Should SAR be above one of those lows, use the lowest of the two for SAR.

    This the foundational calculation for the SAR

    how it related to the trading chart 

    if the SAR Price of the Previous bar is Greater than the High of that bar then this equal a short condition, 

    and if

    SAR Price of the Current Bar is Under The Low of this Bar then this would equal a Long Condition

    so If the Previous bar is Short Condition 

    and 

    The current Bar Become a Long Condition

    The change I want to make is 

    Once the Change from the Short Condition to the Long Condition become true 

    I want the Open Price of the Bar to be 

    The Entry Price at a Stop 

    I hope this helps

    Roger H Hicks



     
    Thursday, November 9, 2017 7:13 AM
  • Hello HICKUNLIMITED,

    I'm not sure the entity class meaning in your program, according to your description I write some pseudo-code represented the actual meaning of your entity class . The logic should be like below.

     Boolean shortcondition = PreviousBar.SarPrice > bar.Hight;
    
                Boolean LongCondition  = CurrentBar.SarPrice < bar.Low;
    
                if (shortcondition && LongCondition) {
    
                    //Open Price of the Bar to be the entry price at a Stop 
    
                }

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by HICKSUNLIMITED Sunday, December 3, 2017 10:35 AM
    Tuesday, November 14, 2017 2:45 AM
    Moderator