MTF Moving Average MT4 MTF MA generuje dowolne typy średnich kroczących w dowolnym czasie. Możesz na przykład codziennie śledzić średnie ruchome na przykład na wykresie 30 m. Pozwala to śledzić wszystko na jednym wykresie. Będziesz miał więcej miejsca na inne pary walutowe. Średnie ruchome są powszechnie stosowane w handlu forex. Są one wykorzystywane do określenia kierunków trendu oraz do wyznaczania stref wsparcia. MTF Moving Average MT4 Indicator 8211 opiera się na średnich kroczących, można go używać do zatrzymywania strat lub regularnego obrotu. Cena powyżej wskaźnika 8211 trend wzrostowy, poniżej tendencji spadkowej. tf 8211 czas okresu źródła 8211 okres przesuwu metody 8211 metoda uśredniania przesunięcia przesunięcia danych 8211 odpowiednioMTF System obrotu SuperTrend - strategie walutowe - zasoby Forex - wolne od forex sygnały handlu forex i prognoza walut 444MTF system handlu SuperTrend wskaźnik MTF Supertrend combo System MTF Supertrend jest czystym trendem po systemie, jego strategią combo opartą na wskaźniku Supertrend i średnim ruchem wykładniczym 5. Ten szablon jest ustawiony na 15-minutową ramkę czasową. Pary walutowe: główne, EURUSD, GBPUSD, AUDUSD, NZDUSD, USDCAD, USDJPY, GBPJPY. Ustawienie wskaźników MetaTradera: Supertrend clear (jest wymagane w przypadku MTF Supertrend) MTF Supertrend (TF 60, CCI 60, ATR -1) Wskaźnik Up Down (HL 4 to wskaźnik działania cenowego i przemalowania) Mnożona średnia ruchoma 5 (średnia cena). Zasady handlu Supertrend MTF System SuperTrend MTF w kolorze linii pomocniczej kolor zielony SuperTrend jasny kolor linii wykresu kolor zielony zielony wskaźnik dolara zielony kropka kolor zielony Jeśli warunki te są zgodne z długą pozycją wejścia, gdy cena wzrośnie do wartości 5EMA. SuperTrend MTF w kolorze linii pomocniczej kolor purpurowy SuperTrend jasny w kolorze linii wykresu czerwony wskaźnik dolny czerwony kolor Jeśli na tych warunkach zgadzają się krótkie pozycje, gdy cena wzrośnie do wartości 5EMA. Te same warunki, ale użyj Supertrend na wykresie, w górę iw dół i 5 Ema. Początkowy stop loss na poprzednim highlow swing. Profit Target 20-30 pipsów lub zarobić na poziomie punktów obrotu. Jak używać średnich kroczących w handlu walutowym Prosta, ale skuteczna strategia ramek z wieloma ramkami. Średnie ruchome (ang. Moving Averages - MAs) w handlu forex są najbardziej prostą, ale skuteczną strategią handlową. Jeśli używasz go w ramce wielozadaniowej (MTF), zawsze będziesz miał najwyższą konfigurację prawdopodobieństwa. Ale co to jest średnia ruchoma Średnia przemieszczająca się jest wskaźnikiem wskazującym tendencję. ponieważ opiera się na wcześniejszych cenach. Biorąc pod uwagę pewien okres czasu dla MA, oznacza, że po każdym zamknięciu pozycja i wartość MA zmienią się. Jest to powód, dla którego MA jest uważany za wskaźnik opadający (pomalowany). Średnia ruchoma średnia (SMA) a średnia ruchoma (EMA) Istnieje wiele typów średnich ruchów, ale te dwie, są najpopularniejszymi: 1. Simple Moving Average (SMA). reprezentują matematyczną średnią cenę pewnego historycznego okresu czasu. Zazwyczaj stosuje się je do cen 8220close8221, ale jest wiele innych opcji (otwarte, wysokie, niskie itp.). 2. Wzór średniej długości wykładniczej (EMA) zmniejsza nieco opóźnienie, zwiększając wagę do niedawnych cen. Szczególnie jeśli używasz dużej wartości dla Twojego EMA. Ie 200 EMA w Daily 8211 ostatnich Daily ceny są większe wagi w Moving Average wzoru, niż najstarsze ceny. Przekazywanie średnich wskazań wskaźnika (wskazanie zegara) Ponieważ ceny na wykresie pomalowane są od lewej do prawej, w zasadzie mamy 2 potencjalne kierunki i 1 dla rynku zasięgu: 1. 82201-2 o8217clock8221 uparty trend 2. 82203 o8217clock8221 zakres lub płaska MA 3. 82204-5 o8217clock8221 trend spadkowy Średnia przemieszczeniowa (EMA) w handlu wieloma ramami (MTF) W obrocie mamy do czynienia z największymi ustawieniami prawdopodobieństwa. Nikt nie może przewidzieć następnych cen. Jeśli jednak weźmiemy pod uwagę kierunek nadrzędnego ramienia czasowego (HTF) i umieść wpis na niższej ramce czasowej (LTF), w tym samym kierunku, będziesz miał więcej szans matematycznych. Dlaczego Ponieważ jakikolwiek wskaźnik opadania, MA, będzie mniej niż HTF. Jak złożyć zamówienie za pomocą EMA Cóż, zależy od rodzaju handlu. Większość przedsiębiorców wolą sprzedawać Breakouts (BO), więc umieszczają BuySell Stop Orending Order. Podczas gdy inni oczekują na ponowne sprawdzenie SupportResistance (SR), więc umieszczają Limit Orending Order. Poprzez umieszczenie takich transakcji stop Loss (SL) jest zazwyczaj na następnym poziomie SR. Lub tylko poniżej Wsparcie dla długich transakcji (lub powyżej oporu dla krótkich transakcji). Osobiście używam poziomów Fibonacci Retracement 50 i 61.8, aby umieścić moje zlecenia oczekujące, w kierunku BO. I używam jako Stop Loss (SL), poziomu 100. Oczywiście, mierząc huśtawkę potwierdzającą EMA8217s BO. W przypadku poziomu Zysku Zarobkowego większość handlowców używa przeciwnego sygnału na wejściu TF (PA przekraczającym 200 EMA) lub następnym poziomie SR. Ale to doesn8217t daje min 1: 3 jako R: R Ratio. Korzystanie z HTF8217s 200 EMA crosingretest może zadziałać. Używam wskaźnika wzrostu Fibonacci na ostatnim trendzie licznika. Więc moja TP może wynosić 127,4, 161,8 i 261,8, szukając min 1: 3, jako mojego współczynnika R: R (RiskReward Ratio). Jeśli moja TP ma co najmniej 3xSL, obniżę TF do H1 i obrót następnym huśtawcem, tam. W ten sposób będę miał gładszą pozycję, z mniejszą SL, a jednocześnie trzymając w teczce TP HTF8217s. Więc mój mniejszy wpis TF będzie próbą. I mogę sobie pozwolić na utratę wielu takich pozycji, aby wyrównać model H48217s SL. To mnie później sprowadza, R: R zwykle przekracza 1: 5 lub 1: 8 lub więcej. Jeśli jesteś Użytkownikiem Pozycji, możesz użyć w ten sposób, trend HTF8217s counter trend retracement Fibonacci. Ale z tego powodu zaleca się przesunięcie początkowej SL co najmniej raz, z zyskiem (aby zablokować swój zysk). Pozwala to na prowadzenie dochodowej pozycji, dopóki nie zostanie uruchomiona TP HTF8217s. Jak uniknąć fałszywych wyprysków Za każdym razem, gdy narzędzie jest złamane, ten wstępny highlow musi zostać złamany, aby potwierdzić Breakout (BO). W przeciwnym razie musimy wziąć pod uwagę, że początkowy BO 8220false BO8221 w testach MA8217s. I ten highlow później stanie się Ross Hook (Rh) lub Fractal. Która oparta na tych teoriach również musi zostać złamana, aby rozważyć zmianę tendencji. W przypadku HTFs testy powtarzane za pomocą fałszywego kodu BO, won8217t zwykle zmieniają wskazanie MA. W przypadku LTF, protokół MA8217s BO może zostać potwierdzony początkowo, tworząc nowy Highlow, który później może zostać unieważniony. A potem, Działanie cen (PA), mogłoby kontynuować kierunek HTF8217. Nawet jeśli protokół LTF8217s BO zostanie potwierdzony, początkowo. Studium przypadku. Przygotuj przykłady EMA do MTF. Aby zrozumieć tę prostą, ale skuteczną strategię handlową opartą na średnich dywizjonach wykładniczych w ramkach wielodyskowych, dam Ci kilka ustawień (scenariuszy): jest to para AUDJPY, na wykresach Tygodniowy, Dzienny i H4. Bazując na 200 EMA wskazującym na uparty, na wszystkich trzech wykresach zajmiemy tylko długie pozycje. 8211 Codziennie długo 8211 Codziennie długie (nawet w przypadku powtórnego testu na 200 EMA, EMA wciąż wskazuje na uparty) 8211 H4 długie (nawet przy 200 EMA powtórzyć z fałszywym zerwaniem, EMA wciąż wskazuje na uparty) Jest to para AUDUSD, Tygodniowy, Dzienny i H4. Na wykresie tygodniowym mamy akcję Cena (PA), poniżej 200 EMA, więc długoterminowy trend jest nadal nieznaczny. Ale na wykresach H4 i Daily PA jest powyżej 200 EMA. Możemy więc poczekać na H4, aby PA znalazł się poniżej 200 EMA (ujemny trend Tygodniowy) i krótko mówiąc. W tym przypadku, po przekroczeniu, 200 EMA musi wskazywać na niechciane, także na H4. Lub możemy czekać na wykres tygodniowy, aby potwierdzić ten sam długie kierunek, później. Poszliśmy ponad 200 EMA na H4, a następnie na Daily. Możemy więc założyć, że PA również przekroczy 200 EMA w Tygodniku. 8211 Tygodniowy krótki 8211 Dzienny długi (nawet w przypadku powtórnego testu na 200 EMA, EMA wciąż wskazuje na uparty) 8211 H4 long To para EURUSD, na wykresach Weekly, Daily i H4. Bazując na 200 EMA wskazującym na uparty, na wszystkich trzech wykresach zajmiemy tylko długie pozycje. Jeśli na H4 PA przekroczy 200 EMA, przestaniemy handlować tą parą. Jeśli później pójdziemy dalej niż PAIiIZ w ciągu dnia, będziemy też czekać na H4, aby PA zjechał poniżej 200 EMA, aby pozyskać krótkie pozycje, spodziewając się co najmniej 200 EMA w ciągu tygodnia ponowne testy (co widać na H4, powinny być postrzegane w Daily, później później i później w Weekly). 8211 Codziennie długi 8211 Codziennie długi (po płaskiej 200 EMA, PA złamał go i wytworzył nową tendencję w tygodniu) 8211 H4 długie (nawet przy 200 EMA powtórzyć, z fałszywym przebiciem wsparcia, EMA nadal wskazując na uparty) Ruchome średnie transakcje w ramach wieloetapowej ramki mogą być bardzo opłacalną strategią, ponieważ zawsze będziesz handlować najwyższymi ustawieniami prawdopodobieństwa, w kierunku ramek z czasem wyższym. Korzystając z dobrego systemu zarządzania pieniędzmi i współczynnika R: R co najmniej 1: 3, zawsze powinieneś być na korzystnej stronie. Oczywiście jako zrzeczenie się zaleca się przetestowanie tej strategii na koncie DEMO, przez kilka miesięcy z rzędu, po to, aby sprawdzić, czy jest to dla Ciebie skuteczne. Jeśli jednak zdecydujesz się na później, użyj tego pomysłu na swoim koncie z prawdziwego pieniądza, powinieneś zrozumieć, że wszystkie związane z tym ryzyko będą Twoim. Mam nadzieję, że to pomaga. Poniższy kod pokazuje, w jaki sposób obecnie generuje się średnią ruchoma do wykorzystania w strategii. Jednak ta średnia ruchoma jest domyślnie ustawiona na ramy czasowe strategii. To, co chciałbym zrobić, to zmiana tej średniej ruchomej, aby mieć oddzielną ramkę czasową oddzieloną od tej stosowanej w pozostałej części strategii. Używałem różnych pomysłów, ale nic nie działa, chciałbym bardzo docenić, jeśli ktoś mógłby pokazać mi, jak to zrobić z poniższym przykładowym kodem: nb. Proszę również uwzględnić wszelkie zmiany potrzebne do pierwszego () obliczeń. strategii. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotWilderquot, kwotowanie, quotWilderquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot). parametry: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategia. parametry: addStringAlternative (kwTrendMAMethodquot, quotHMAquot, podaj kwotę, kwot, kwotę, kwotę kwotową, kwotowanie, kwotowanie, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, kwotowanie kwotowe, addStringAlternative (quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategie. parameters: addStringAlternativ e (quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strateg. parameters: addInteger (quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strateg. parameters: addString (nazywanaTypequot, quotPrice Typequot, quotquot , quotCquot) strategia. parametry: addStringAlternative (quotTypequot, quotOPENquot, quotquot, quotOquot) strateg. parameters: addStringAlternative (quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters: addStringAlternative (quotTypequot, quotLOWquot, quotquot, quotLquot) strategia. parametry: addStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategia. parametry: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) strateg. parameters: addStringAlternative (quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategia. parameters: addStringAlternative (quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot ) strate gy. parameters: addGroup (quotPricequot) strategy. parameters: addString (quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strateg. parameters: addStringAlternative (quotPTquot, quotBidquot, quotquot, quotBidquot) strategie. parametry: addStringAlternative (quotPTquot, quotAskquot, quotquot, quotAskquot ) strategia. parametry: addGroup (quotTimeFramequot) strategia. parametry: addString (quotTFquot, quotTime Framequot, quotquot, quotm5quot) strateg. parameters: setFlag (quotTFquot, core. FLAGPERIODS) kończące lokalne gSource - strumienie lokalnego TrendMAMethod local TrendMAPeriod local TrendMA local P1 TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gSource ExtSubscribe (1, nil, instance. parameters. TF, instance. parameters. Type quotBidquot, quotbarquot) jeśli Type1 quotOquot następnie P1 gSource. open elseif Type1 quotHquot a następnie P1 gSource. high elseif Type1 quotLKtóre następnie P1 gSource. low elseif Type1 quotMquot, a następnie P1 gSource. median elseif Type1 quotTquot a następnie P1 gSource. typical elseif Type1 quotWquot, a następnie P1 gSource. weighted else P1 gSource. close end TrendMA core. indicators: create (quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) - i pobierz najstarszy indeks paska, który możemy najpierw pracuj w math. max (TrendMA. DATA:first (). itp.) end function ExtUpdate (identyfikator, źródło, okres) - jeśli mamy wystarczająco dużo pasków w historii, aby działać, jeśli okres gt pierwszy 1 Teraz Teraz mogę używać subskrybowania MA do innego harmonogramu Kod: Zaznacz wszystkie gBTFSource ExtSubscribe (BTFID, nil, instance. parameters. BTF, instance. parameters. Type quotBidquot, quotbarquot) i używać go w wskaźniku zamiast gSource Code: Zaznacz wszystkie P1 gBTFSource. open. Aby uzyskać indeks pierwszej wartości, należy podać indeks konwersji w głównym ramy czasowej do indeksu większych ram czasowych, takich jak: Kod: Zaznacz wszystkie pierwsze dane TrendMA. DATA:first (). local btfPeriod core. findDate (gBTFSource, gSource: date (period), true) jeśli btfPeriod gt first 1, a następnie wpisz poprawki tutaj: Kod: Zaznacz wszystkie funkcje Init () strategy. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot ) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, kwotowanie, quotMVAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategie. parameters: addStringAlternative (quotTrendMAMethodquot , quotLWMAquot, quotquot, quotLWMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategia. param Zastosowano cewniki: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotDEMAquot, , quotITrququot, kwquot, quotITrendquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategia. parameters: addStringAlternative (quotTrendMAMethodquot, addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotILRSquot , kwotowanie, quotILRSquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategie. parameters: addStringAlternative (quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strateg. parameters : addInteger (quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strateg. parameters: addString (quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategia. parameters: addStringAlternative (quotTypequot, quotPENquot, quotquot, quotOquot) strategia. parametry: addStringAlternative (nazywanaTypequot, quotHIGHquot, quot; quotquot, quotHquot) strategia. parametry: addStringAlternative (quotTypequot, quotLOWquot, quotquot, quotLquot) strategia. parametry: addStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategia. parametry: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters: addStrin gAlternative (quotTypequot, quotTYPICALquot, quotquot, quotTquot) strateg. parameters: addStringAlternative (quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategia. parametry: addGroup (quotPricequot) strategia. parametry: addString (quotPTquot, quotPrice Typequot, kwotowanie, quotBidquot) strateg. parameters : addStringAlternative (quotPTquot, quotBidquot, quotquot, quotBidquot) strategia. parametry: addStringAlternative (quotPTquot, quotAskquot, quotquot, quotAskquot) strateg. parameters: addGroup (quotTimeFramequot) strategie. parametry: addString (kwitTFQuot, quotTime Framequot, kwotowanie, quotm5quot) strategia. Parametry: setFlag (quotTFQuot, core. FLAGPERIODS) strategia. parameters: addString (kwitBTFquot, kwerenda Time Framequot, quotquot, quotH1quot) strategia. parameters: setFlag (quotBTFquot, core. FLAGPERIODS) kończące lokalne gSource - strumienie lokalnego gBTstreamource - strumienie lokalnego TrendMAMethod lokalny TrendMAPeriod lokalny TrendMA lokalny P1 lokalny MAINTFID 1 lokalny BTFID 2 TrendMAMethodinstance. parameters. TrendMA Metoda TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gSource ExtSubscribe (MAINTFID, nil, instancja. parameters. TF, instancja. parameters. Type quotBidquot, quotbarquot) gBTFSource ExtSubscribe (BTFID, nil, instancji. parameters. BTF, instancji. parametrów. Wpisz quotBidquot, quotbarquot), jeśli Type1 quotOquot, a następnie P1 gBTFSource. open elseif Type1 quotHquot, a następnie P1 gBTFSource. high elseif Type1 quotLquot, a następnie P1 gBTFSource. low elseif Type1 quotMquot, a następnie P1 gBTFSource. median elseif Type1 quotTquot, a następnie P1 gBTFSource. typical elseif Type1 quotWquot a następnie P1 gBTFSource. weighted else P1 gBTFSource. close end TrendMA core. indicators: create (kwARERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) - i uzyskaj najstarszy indeks paska, na którym możemy pracować w pierwszej funkcji TrendMA. DATA :first () ExtUpdate (identyfikator, źródło, okres), jeśli id MAINTFID i gBTFSource: size () gt 0, a następnie TrendMA: update (core. UpdateLast) lokalny btfPeriod core. findDate (gBTFSource, gSource: date (period), t rue) - jeśli mamy wystarczająco dużo barów w historii, jeśli btfPeriod gt first 1 - teraz mogę używać końca końcówki MA Jest tylko trzy sporty: walka byków, wyścigi motocyklowe i alpinizm, reszta to tylko gry . (c) Ernest Hemingway Cześć Victor. Tereschenko, dziękuję bardzo Wiktorowi, że to była wielka pomoc, ale nadal jestem zablokowana w następujący sposób: - Pełny kod jest poniżej, umieszczałem kilka sygnałów (Test Points) w celu monitorowania postępów poprzez logikę i stwierdził, że kod nie był na linii: 284 jeśli btfPeriod gt pierwszy 1, to wartości okazały się następujące: - EURUSD LONNY02SIGNAL, EURUSD, cci20, m1, oba 2 TP0 - START: btfPeriod (-1) gt pierwszy (199) 1 08252017 10:08:00 1.44073 Problem jest oczywiście btfPeriod na -1, wskazując, że Ive zrobił blooper gdzieś najprawdopodobniej, czy jesteś w stanie zobaczyć problem Wielkie dzięki Peter Newton Code: Wybierz wszystko - Opublikuj strategię do aplikacja hosta (na przykład Marketscope). - Funkcja jest wywoływana raz, gdy aplikacja hosta wstępnie załaduje strategię. - strategie szybkiego i powolnego przecięcia parametrów strategicznych. parametry: addGroup (quotMain Controlsquot) strategy. parameters: addString (quotTFQuot, quotStrategy Time Framequot, quotquot, quotm5quot) Strategia: nazwa (quotLonNY02Signalquot) strategia: opis (quotLonNY02 Signaling Strategyquot) ) strategia. parameters: setFlag (quotTFQuot, core. FLAGPERIODS) strategy. parameters: addString (nazywanyCLOSEZZwierzętą, quotAllowed sidequot, quotAllowed side for trading or signaling, może być Sell, Buy lub Bothquot, quotBotquot) strategia. parameters: addStringAlternative (quotALLOWEDSIDEquot, quotBotquot , quotquot, quotBotquot) strategia. parametry: addStringAlternative (quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) strateg. parameters: addStringAlternative (quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) strategia. parametry: addBoolean (kwit, kwerenda, kwerenda Alertquot, kwota, prawda). parametry: addBoolean (quotTquot, quotTrigger Alertquot, quotquot, true) strategia. parameters: addBoolean ( (atrybut_wymagania_wymagania, kwerendy, kwquot, true) strategia. parametry: addGroup (quotAlertsquot) strateg. parameters: addBoolean (quotShowAlertquot, quotShowAlertquot, quotquot, true) strateg. parameters: addBoolean (quotPlaySoundquot, quotPlay Soundquot, quotquot, true) : addFile (quotSoundFilequot, quotSound FileQuot, quotquot, quotquot) strateg. parameters: setFlag (quotSoundFilequot, core. FLAGSOUND) strategy. parameters: addBoolean (quotRecurrentSoundquot, quotRecurrent Soundquot, quotquot, true) strategia. parameters: addBoolean (quotSendEmailquot, quotSend Emailquot, kwerendę, kwerendę, false) strategia. parameters: addString (quotEmailquot, quotEmailquot, quotquot, quotquot) strategia. parameters: setFlag (quotEmailquot, core. FLAGEMAIL) strateg. parameters: addGroup (quotCCI Parameterquot) strategy. parameters: addInteger (kwotaCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) strategia. parameters: addGroup (ramka MA Parametr czas trwania błysku) strategia. parameters: addBoolean (quotBTFMAFl agquot, timeBigger Czas ramki MA Trendy onquot, quotquot, true) strateg. parameters: addString (quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategie. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategie. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotEMAquot , quotquot, quotEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters : addStringAlternative (quotBTFTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strateg. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategia. parametry: addStringAlternative (kwitBTFTrendMAMethodquot, quotSMMAquot, quotquot , quotSMMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot ) strateg. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategia. parametry: addStringAlternative (kwitBTFTrendMAMethodquot, quotILRSquot, kwotowanie, quotILRSquot) strateg. parameters : AddStringAlternative (quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters: addStringAlternative (quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters: addstring (quotBTFTypequot, quotBTFPrice Typequot, quot; quotquot, quotCquot) strategia. parametry: addStringAlternative (quotBTFTypequot, quotPENquot, quotquot, quotOquot) strategia. parametry: addStringAlternative (quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) strategia. parametry: addStringAlternative (quotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategia. parameters: addStringAlternative (quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strateg. parameters: addStringAlternative (quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) strateg. parameters: addStringAlternative (kwitBTFTypequot, quotTYPICALquot, quotquot, quotTquot) strateg. parameters: addStringAlternativ e (kwotaBTFTypequot, quotIMEIGHTquant, quotquot, quotWquot) strategia. parameters: addInteger (quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strateg. parameters: addString (quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) strategia. parameters: setFlag (quotBTFquot, core). FLAGPERIODS) strategia. parameters: addGroup (parametrStrategy ramki czasowej MA Parameterquot) strategia. parameters: addBoolean (quotStrategyMAFlagquot, quotStrategy MA Trendy onquot, quotquot, true) strategia. parameters: addString (quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategie. parametry: addStringAlternative (quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot ) strategia. para m: addStringAlternative (quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters: addStringAlternative (quotTrendMAMethodquot, quotSMMAquot, , quotStringAlternative (quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategia. parameters: addStringAlternative (quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategia. parameters: addStringAlternative (quotTrendMAMethodquot, quotZeroLagEMAquot, kwquot, quotZeroLagEMAquot) strateg. parameters: strategia: parametry addStringAlternative (quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters: addStringAlternative (kwTrendMAMethodquot, quotMedianquo t, quotquot, quotMedianquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategia. Parametry: addStringAlternative (quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strateg. parameters: addStringAlternative (quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategia. parametry: addStringAlternative (quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSm runquot) strategia. parametry: addString (kwotaTypequot, quotPrice Typequot , quotquot, quotCquot) strategia. parametry: addStringAlternative (quotTypequot, quotOPENquot, quotquot, quotOquot) strateg. parameters: addStringAlternative (quotTypequot, quotHIGHquot, quotquot, quotHquot) strateg. parameters: addStringAlternative (quotTypequot, quotLOWquot, quotquot , quotLquot) strategia. parametry: addStringAlternative (quotTypequot, quotCLOSEquot, quotquot, quotCquot) strateg. parameters: addStringAlternative (quotTypequot, quotMEDIANquot, quotquot, quotMquot) strateg. parameters: addStringAlternative (nazywanaTypequot, quotTYPICALquot, quotquot, quotTquot) strateg. parameters: addStringAlternative (quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategia. parametry: addInteger (quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strateg. parameters: addGroup (quotLevelsquot) strategy. parameters: addInteger (kwota kwotowa, quotOverbought Levelquot, quotquot, 100) parametry strategiczne: addInteger (quotOSquot, quot Oversold Levelquot, quotquot, -100) strateg. parameters: addInteger (quotOBCquot, quotOverbought Potwierdzenie Levelquot, quotquot, 150) strateg. parameters: addInteger (quotOSCquot, poziom Oversold Potwierdzenie, kwotowanie, -150) - Cena parametry subskrypcji (cena ofertowa lub cena zapytania, rama czasowa) strategia. parametry: addGroup (quotPricequot). parametry: addString (quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strategia. parametry: addStringAlternative (quotPTquot, quotBidquot, quotquot, quotBidquot) strategia. parametry: addStringAlternative (quotPTquot, quotAskquot, quotquot, quotAskquot) - zmienne globalne lokalne BAR zero - - historię cen, którą subskrybowano lokalnie - indeks najstarszego okresu, w którym możemy sprawdzić, czy przecenione średnie ruchy zostały przekroczone lokalnie OB, OS, OBC, OSC lokalny CCI lokalny Top, dolny lokalny gBTFSource - strumieni lokalnego BTFTrendMAMethod lokalnego BTFTrendMAPeriod lokalny BTFTrendMA local gSource - strumieni lokalny TrendMAMethod lokalny TrendMAPeriod lokalny TrendMA lokalny upArrow zerowy lokalny downArrow zerowy lokalny MAINTFID 1 lokalny BTFID 2 lokalny BTFP1 lokalny BTFType lokalny SoundFile zerowy lokalny RecurrentSound false lokalny ALLOWEDSIDE lokalny S-Setup lokalny lokalny T - wyzwalacz lokalny CT - - Potwierdzony Trigger local lookBack lokalne ShowAlert local Email local SendEmail Lokalna funkcja BaseSize Przygotuj () - Przygotuj wszystkie d ata. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT --downArrow instance:createTextOutput (quotUpquot, quotUpquot, quotWingdings 3quot, 20, core. HCenter, core. VTop, instance. parameters. Bottom, 0) --upArrow instance:createTextOutput (quotDownquot, quotDownquot, quotWingdings 3quot, 20, core. HCenter, core. VBottom, instance. parameters. Top, 0) quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we dont check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(1, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gSource ExtSubscribe(MAINTFID, nil, instance. parameters. TF, instance. parameters. Type quotBidquot, quotbarquot) gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 gSource. open elseif Type quotHquot then P1 gSource. high elseif Type quotLquot then P1 gSource. low elseif Type quotMquot then P1 gSource. median elseif Type quotTquot then P1 gSource. typical elseif Type quotWquot then P1 gSource. weighted else P1 gSource. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first(), BTFTrendMA. DATA:first()) end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id 1 then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if id MAINTFID and gBTFSource:size() gt 0 then TrendMA:update(core. UpdateLast) local btfPeriod core. findDate(gBTFSource, gSource:date(period), true) -- if we have enough bars in the history to work Signal (quotTP0 - START: btfPeriod(quot. tostring(btfPeriod). quot) gt first(quot. tostring(first). quot) 1quot ) if btfPeriod gt first 1 then Signal (quotTP0a - quot. quotbtfPeriod gt first 1quot) -- This bit added for signalling only if BTFMAFlag then if gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end else BTFdir quotOffquot Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if gSource. close91period93 lt TrendMA. DATA91period93 then Signal (quotTP4 - trend Downquot) trendDdir quotDownquot elseif gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 then Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWE DSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySound if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end You have sent id into subscribe: BAR ExtSubscribe(1. ) When update is called with id 1, the period is valid for the BAR source only. gBTFSource has different timeframe and the period with id 1 is not valid to it. You should use converted period (btfPeriod) to access gBTFSourceBTFTrendMA values. Code: Select all gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 instead of Code: Select all gBTFSource. close91period93 lt BTFTrendMA. DATA91period93 first value should be quotsplittedquot into two: Code: Select all first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() . if period gt first then . -- and if btfPeriod gt btfFirst then And Ive made a misprint over here: Code: Select all --local btfPeriod core. findDate(gBTFSource, BAR:date(period), true) local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) Corrected code: Code: Select all -- Intoduce the strategy to the host application (for example, Marketscope). -- The function is called once when the host application initially loads the strategy. function Init() strategy:name(quotLonNY02Signalquot) strategy:description(quotLonNY02 Signalling Strategyquot) -- Fast and slow moving average parameters strategy. parameters:addGroup(quotMain Controlsquot) strategy. parameters:addString(quotTFquot, quotStrategy Time Framequot, quotquot, quotm5quot) strategy. parameters:setFlag(quotTFquot, core. FLAGPERIODS) strategy. parameters:addString(quotALLOWEDSIDEquot, quotAllowed sidequot, quotAllowed side for trading or signaling, can be Sell, Buy or Bothquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotBothquot, quotquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) strategy. parameters:addBoolean(quotSquot, quotSetup Alertquot, quotquot, true) strategy. parameters:addBoolean(quotTquot, quotTrigger Alertquot, quotquot, true) strategy. parameters:addBoolean( quotCTquot, quotConfirmed Trigger Alertquot, quotquot, false) strategy. parameters:addGroup(quotAlertsquot) strategy. parameters:addBoolean(quotShowAlertquot, quotShowAlertquot, quotquot, true) strategy. parameters:addBoolean(quotPlaySoundquot, quotPlay Soundquot, quotquot, true) strategy. parameters:addFile(quotSoundFilequot, quotSound Filequot, quotquot, quotquot) strategy. parameters:setFlag(quotSoundFilequot, core. FLAGSOUND) strategy. parameters:addBoolean(quotRecurrentSoundquot, quotRecurrent Soundquot, quotquot, true) strategy. parameters:addBoolean(quotSendEmailquot, quotSend Emailquot, quotquot, false) strategy. parameters:addString(quotEmailquot, quotEmailquot, quotquot, quotquot) strategy. parameters:setFlag(quotEmailquot, core. FLAGEMAIL) strategy. parameters:addGroup(quotCCI Parameterquot) strategy. parameters:addInteger(quotCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) strategy. parameters:addGroup(quotBigger Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotBTFMAFl agquot, quotBigger Time Frame MA Trend onquot, quotquot, true) strategy. parameters:addString(quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSMMAquot, quotquot , quotSMMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters :addStringAlternative(quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotBTFTypequot, quotBTFPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternativ e(quotBTFTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strategy. parameters:addString(quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) strategy. parameters:setFlag(quotBTFquot, core. FLAGPERIODS) strategy. parameters:addGroup(quotStrategy Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotStrategyMAFlagquot, quotStrategy MA Trend onquot, quotquot, true) strategy. parameters:addString(quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. para meters:addStringAlternative(quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMedianquo t, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotTypequot, quotLOWquot, quotquot , quotLquot) strategy. parameters:addStringAlternative(quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters:addGroup(quotLevelsquot) strategy. parameters:addInteger(quotOBquot, quotOverbought Levelquot, quotquot, 100) strategy. parameters:addInteger(quotOSquot, quot Oversold Levelquot, quotquot, -100) strategy. parameters:addInteger(quotOBCquot, quotOverbought Confirmation Levelquot, quotquot, 150) strategy. parameters:addInteger(quotOSCquot, quot Oversold Confirmation Levelquot, quotquot, -150) -- Price subscription parameters (bid or ask price, time frame) strategy. parameters:addGroup(quotPricequot) strategy. parameters:addString(quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotAskquot, quotquot, quotAskquot) -- The global variables local BAR nil -- the price history we subscribed for local first -- the index of the oldest period where we can check whether moving averages has been crossed local btfFirst local OB, OS, OBC, OSC local CCI local Top, Bottom local gBTFSource -- streams local BTFTrendMAMethod local BTFTrendMAPeriod local BTFTrendMA local TrendMAMethod local TrendMAPeriod local TrendMA local upArrow nil local downArrow nil local STRATTFID 1 local BTFID 2 local BTFP1 local BTFType local SoundFile nil local RecurrentSound false local ALLOWEDSIDE local S -- Setup local T -- Trigger local CT -- Confirmed Trigger local lookBack local ShowAlert local Email local SendEmail local BaseSize function Prepare() -- Prepare all the data. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT --downArrow instance:createTextOutput (quotUpquot, quotUpquot, quotWingdings 3quot, 20, core. HCenter, core. VTop, instance. parameters. Bottom, 0) --upArrow instance:createTextOutput (quotDownquot, quotDownquot, quotWingdings 3quot, 20, core. HCenter, core. VBottom, instance. parameters. Top, 0) quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we dont check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(STRATTFID, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 BAR. open elseif Type quotHquot then P1 BAR. high elseif Type quotLquot then P1 BAR. low elseif Type quotMquot then P1 BAR. median elseif Type quotTquot then P1 BAR. typical elseif Type quotWquot then P1 BAR. weighted else P1 BAR. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id STRATTFID and period gt first then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if gBTFSource:size() gt 0 then local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) -- if we have enough bars in the history to work Signal (quotTP0 - START: btfPeriod(quot. tostring(btfPeriod). quot) gt first(quot. tostring(first). quot)quot ) if btfPeriod gt btfFirst then Signal (quotTP0a - quot. quotbtfPeriod gt btfFirstquot) -- This bit added for signalling only if BTFMAFlag then if gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end else BTFdir quotOffquot Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if BAR. close91period93 lt TrendMA. DATA91period93 then Signal (quotTP4 - trend Downquot) trendDdir quotDownquot el seif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySound if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end There are only three sports: bullfighting, motor racing, and mountaineering all the rest are merely games. (c) Ernest Hemingway Hi Victor, Ive been correcting some of my typose too. This is getting really close now but problems still persist, this is now with line 295 as follows if gBTFSource. closebtfPeriod lt BTFTrendMA. DATAbtfPeriod then. the error is quotindex out of rangequot the values are as follows:- gBTFSource. close299 (1.44306) lt BTFTrendMA. DATA299 ( ) (btfFirst 199) I separated the two sides out into 2 lines as follows:- -- This works ok local y gBTFSource. closebtfPeriod -- this one gives ERROR INDEX OUT OF RANGE (does this line look right to you) local x BTFTrendMA. DATAbtfPeriod BTFTrendMA is created as follows: BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) Is there something wrong with this line if not Im Now out of ideas to track this further Full code here Code: Select all -- Intoduce the strategy to the host application (for example, Marketscope). -- The function is called once when the host application initially loads the strategy. function Init() strategy:name(quotLonNYBTFsignalquot) strategy:description(quotLonNY Bigger Time Frame Signalling Strategyquot) -- Fast and slow moving average parameters strategy. parameters:addGroup(quotMain Controlsquot) strategy. parameters:addString(quotTFquot, quotStrategy Time Framequot, quotquot, quotm5quot) strategy. parameters:setFlag(quotTFquot, core. FLAGPERIODS) strategy. parameters:addString(quotALLOWEDSIDEquot, quotAllowed sidequot, quotAllowed side for trading or signaling, can be Sell, Buy or Bothquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotBothquot, quotquot, quotBothquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotUpquot, quotquot, quotUpquot) strategy. parameters:addStringAlternative(quotALLOWEDSIDEquot, quotDnquot, quotquot, quotDnquot) strategy. parameters:addBoolean(quotSquot, quotSetup Alertquot, quotquot, false) strategy. parameters:addBoolean(quotTquot, quotTrigger Alertquot, quotquot, true) strategy. param eters:addBoolean(quotCTquot, quotConfirmed Trigger Alertquot, quotquot, false) strategy. parameters:addGroup(quotAlertsquot) strategy. parameters:addBoolean(quotShowAlertquot, quotShowAlertquot, quotquot, true) strategy. parameters:addBoolean(quotPlaySoundquot, quotPlay Soundquot, quotquot, true) strategy. parameters:addFile(quotSoundFilequot, quotSound Filequot, quotquot, quotquot) strategy. parameters:setFlag(quotSoundFilequot, core. FLAGSOUND) strategy. parameters:addBoolean(quotRecurrentSoundquot, quotRecurrent Soundquot, quotquot, true) strategy. parameters:addBoolean(quotSendEmailquot, quotSend Emailquot, quotquot, false) strategy. parameters:addString(quotEmailquot, quotEmailquot, quotquot, quotquot) strategy. parameters:setFlag(quotEmailquot, core. FLAGEMAIL) strategy. parameters:addGroup(quotCCI Parameterquot) strategy. parameters:addInteger(quotCCIPquot, quotCCI periodquot, quotquot, 20, 2, 200) strategy. parameters:addGroup(quotBigger Time Frame MA Parameterquot) strategy. parameters:addBo olean(quotBTFMAFlagquot, quotBigger Time Frame MA Trend onquot, quotquot, true) strategy. parameters:addString(quotBTFTrendMAMethodquot, quotBTFTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotS MMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) st rategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotBTFTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotBTFTypequot, quotBTFPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotLOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotBTFTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:ad dStringAlternative(quotBTFTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotBTFTrendMAPeriodquot, quotBTFTrendMAPeriodquot, quotquot, 200) strategy. parameters:addString(quotBTFquot, quotBigger Time Framequot, quotquot, quotm30quot) strategy. parameters:setFlag(quotBTFquot, core. FLAGPERIODS) strategy. parameters:addGroup(quotStrategy Time Frame MA Parameterquot) strategy. parameters:addBoolean(quotStrategyMAFlagquot, quotStrategy MA Trend onquot, quotquot, true) strategy. parameters:addString(quotTrendMAMethodquot, quotTrendMAMethodquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotMVAquot, quotquot, quotMVAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotEMAquot, quotquot, quotEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotWilderquot, quotquot, quotWilderquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLWMAquot, quotquot, quotLWMAqu ot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSineWMAquot, quotquot, quotSineWMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAquot, quotquot, quotTriMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotLSMAquot, quotquot, quotLSMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotSMMAquot, quotquot, quotSMMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotHMAquot, quotquot, quotHMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotZeroLagEMAquot, quotquot, quotZeroLagEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotDEMAquot, quotquot, quotDEMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotT3quot, quotquot, quotT3quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotITrendquot, quotquot, quotITrendquot) strategy. parameters:addStringAlternative(quotTrendMAMethodqu ot, quotMedianquot, quotquot, quotMedianquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotGeoMeanquot, quotquot, quotGeoMeanquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotREMAquot, quotquot, quotREMAquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotILRSquot, quotquot, quotILRSquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotIE2quot, quotquot, quotIE2quot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotTriMAgenquot, quotquot, quotTriMAgenquot) strategy. parameters:addStringAlternative(quotTrendMAMethodquot, quotJSmoothquot, quotquot, quotJSmoothquot) strategy. parameters:addString(quotTypequot, quotPrice Typequot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotOPENquot, quotquot, quotOquot) strategy. parameters:addStringAlternative(quotTypequot, quotHIGHquot, quotquot, quotHquot) strategy. parameters:addStringAlternative(quotTypequot, quot LOWquot, quotquot, quotLquot) strategy. parameters:addStringAlternative(quotTypequot, quotCLOSEquot, quotquot, quotCquot) strategy. parameters:addStringAlternative(quotTypequot, quotMEDIANquot, quotquot, quotMquot) strategy. parameters:addStringAlternative(quotTypequot, quotTYPICALquot, quotquot, quotTquot) strategy. parameters:addStringAlternative(quotTypequot, quotWEIGHTEDquot, quotquot, quotWquot) strategy. parameters:addInteger(quotTrendMAPeriodquot, quotTrendMAPeriodquot, quotquot, 200) strategy. parameters:addGroup(quotLevelsquot) strategy. parameters:addInteger(quotOBquot, quotOverbought Levelquot, quotquot, 100) strategy. parameters:addInteger(quotOSquot, quot Oversold Levelquot, quotquot, -100) strategy. parameters:addInteger(quotOBCquot, quotOverbought Confirmation Levelquot, quotquot, 150) strategy. parameters:addInteger(quotOSCquot, quot Oversold Confirmation Levelquot, quotquot, -150) -- Price subscription parameters (bid or ask price, time frame) strategy. parameters:addGroup(quotPri cequot) strategy. parameters:addString(quotPTquot, quotPrice Typequot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotBidquot, quotquot, quotBidquot) strategy. parameters:addStringAlternative(quotPTquot, quotAskquot, quotquot, quotAskquot) -- The global variables local BAR nil -- the price history we subscribed for local first -- the index of the oldest period where we can check whether moving averages has been crossed local btfFirst local OB, OS, OBC, OSC local CCI local Top, Bottom local gBTFSource -- streams local BTFTrendMAMethod local BTFTrendMAPeriod local BTFTrendMA local BTFtrendDir local TrendMAMethod local TrendMAPeriod local TrendMA local trendDir local STRATTFID 1 local BTFID 2 local BTFP1 local BTFType local SoundFile nil local RecurrentSound false local ALLOWEDSIDE local S -- Setup local T -- Trigger local CT -- Confirmed Trigger local lookBack local ShowAlert local Email local SendEmail local BaseSize function Prepare() -- Prepare all the data. -- The function is called once when the strategy is about to be started. -- check moving average parameters OBinstance. parameters. OB OS instance. parameters. OS OBC instance. parameters. OBC OSC instance. parameters. OSC CCIP instance. parameters. CCIP Sinstance. parameters. S Tinstance. parameters. T CTinstance. parameters. CT quott1quot, quotThe strategy cannot be applied on ticks. quot) -- name the indicator local name profile:id(). quot, quot. instance. bid:name(). quot, cciquot. CCIP. quot, quot. instance. parameters. TF. quot, quot. ALLOWEDSIDE. quot quot instance:name(name) -- setup the signal. pay attention, we pass quotShowAlertquot (value initially taken from the instance. parameters. ShowAlert) -- here, so, we don-t check whether alerts are requested anymore. -- and finally subscribe for the ticks of the instrument the user initially chosen to run the strategy for to -- have our strategy activated once. BAR ExtSubscribe(STRATTFID, nil, instance. parameters. TF, true, quotbarquot) -- create indicators CCI core. indicators:create(quotCCIquot, BAR, CCIP) BTFTrendMAMethodinstance. parameters. BTFTrendMAMethod BTFTrendMAPeriodinstance. parameters. BTFTrendMAPeriod BTFTypeinstance. parameters. BTFType BTFMAFlag instance. parameters. BTFMAFlag TrendMAMethodinstance. parameters. TrendMAMethod TrendMAPeriodinstance. parameters. TrendMAPeriod Typeinstance. parameters. Type MAFlag instance. parameters. MAFlag gBTFSource ExtSubscribe(BTFID, nil, instance. parameters. BTF, instance. parameters. BTFType quotBidquot, quotbarquot) if BTFType quotOquot then BTFP1 gBTFSource. open elseif BTFType quotHquot then BTFP1 gBTFSource. high elseif BTFType quotLquot then BTFP1 gBTFSource. low elseif BTFType quotMquot then BTFP1 gBTFSource. median elseif BTFType quotTquot then BTFP1 gBTFSource. typical elseif BTFType quotWquot then BTFP1 gBTFSource. weighted else BTFP1 gBTFSource. close end if Type quotOquot then P1 BAR. open elseif Type quotHquot then P1 BAR. high elseif Type quotLquot then P1 BAR. low elseif Type quotMquot then P1 BAR. median elseif Type quotTquot then P1 BAR. typical elseif Type quotWquot then P1 BAR. weighted else P1 BAR. close end BTFTrendMA core. indicators:create(quotAVERAGESquot, BTFP1, BTFTrendMAMethod, BTFTrendMAPeriod, false) TrendMA core. indicators:create(quotAVERAGESquot, P1, TrendMAMethod, TrendMAPeriod, false) -- and get the oldest index of the bar we can work at first math. max(CCI. DATA:first(), TrendMA. DATA:first()) btfFirst BTFTrendMA. DATA:first() end -- the function is called every time when any subscribed price is changed. For tick subscribtions the function is called -- for every tick, for the bar subscribtions the function is called when the candle is closed (in other words, when -- the first tick of the next candle appears). function ExtUpdate(id, source, period) if id STRATTFID and period gt first then -- on the user chosen subscription (can be either tick or bar subscribtion). -- update indicators CCI:update(core. UpdateLast) TrendMA:update(core. UpdateLast) -- if we have enough bars in the history to work if gBTFSource:size() gt 0 then local btfPeriod core. findDate(gBTFSource, BAR:date(period), false) -- if we have enough bars in the history to work if btfPeriod gt btfFirst then -- This works ok local y gBTFSource. close91btfPeriod93 -- this one gives ERROR INDEX OUT OF RANGE local x BTFTrendMA. DATA91btfPeriod93 -- This bit added for signalling only if BTFMAFlag true then Signal(quotgBTFSource. close91quot. tostring(btfPeriod). quot93 (quot. tostring(gBTFSource. close91btfPeriod93). quot) lt BTFTrendMA. DATA91quot. tostring(btfPeriod). quot93 ( ) (btfFirst quot. tostring(btfFirst)) if gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then --Signal (quotTP1 - BTFtrend Downquot) BTFtrendDir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then --Signal (quotTP2 - BTFtrend Upquot) BTFtrendDir quotUpquot end el se BTFdir quotOffquot --Signal (quotTP3 - BTFtrend Offquot) end if MAFlag then if BAR. close91period93 lt TrendMA. DATA91period93 then -- Signal (quotTP4 - trend Downquot) trendDdir quotDownquot elseif gBTFSource. close91btfPeriod93 lt BTFTrendMA. DATA91btfPeriod93 then -- Signal (quotTP5 - trend Upquot) trendDdir quotUpquot end else trendDdir quotOffquot --Signal (quotTP6 - trend Offquot) end if S and core. crossesOver(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal ( quotSell Setup: Crossing above OverBoughtquot) elseif S and core. crossesUnder(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Setup: Crossing Below OverSoldquot) end if T and core. crossesOver(CCI. DATA , OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then Signal (quotBuy Trigger: Crossing above OverSoldquot) elseif T and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end if core. crossesOver(CCI. DATA, OBC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP true end if core. crossesUnder(CCI. DATA, OSC, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM true end if CT and core. crossesOver(CCI. DATA, OS, period) and (BTFtrendDir quotUpquot or BTFtrendDir quotOffquot) and (trendDir quotUpquot or trendDir quotOffquot) and BOTTOM and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotUpquot) then BOTTOM false Signal (quotBuy Trigger: Confirmed Crossing above OverSoldquot) elseif CT and core. crossesUnder(CCI. DATA, OB, period) and (BTFtrendDir quotDownquot or BTFtrendDir quotOffquot) and (trendDir quotDownquot or trendDir quotOffquot) and TOP and (ALLOWEDSIDE quotBothquot or ALLOWEDSIDE quotDnquot) then TOP false Signal (quotSell Trigger: Confirmed Crossing below OverBoughtquot) end -- end of confirmation trigger signalling end end end end -- eof function ExtUpdate function Initialization() AllowMultiple instance. parameters. AllowMultiple ALLOWEDSIDE instance. parameters. ALLOWEDSIDE --local S instance. parameters. S --local T instance. parameters. T --local CT instance. parameters. CT local PlaySound instance. parameters. PlaySo und if PlaySound then SoundFile instance. parameters. SoundFile else SoundFile nil end assert(not(PlaySound) or (PlaySound and SoundFile quotquot), quotSound file must be chosenquot) ShowAlert instance. parameters. ShowAlert RecurrentSound instance. parameters. RecurrentSound SendEmail instance. parameters. SendEmail if SendEmail then Email instance. parameters. Email else Email nil end assert(not(SendEmail) or (SendEmail and Email quotquot), quotE-mail address must be specifiedquot) end function Signal (Label) if ShowAlert then terminal:alertMessage(instance. bid:instrument(), instance. bid91NOW93, Label, instance. bid:date(NOW)) end nil then terminal:alertSound(SoundFile, RecurrentSound) end nil then terminal:alertEmail(Email, Label, profile:id(). quot(quot. instance. bid:instrument(). quot)quot. instance. bid91NOW93..quot, quot. Label..quot, quot. instance. bid:date(NOW)) end end
No comments:
Post a Comment